Support all Taiwan IDs

#3 · closed · 4 comments

View on GitHub ↗

fifieldt

Hi, Thanks for the code! There's a couple of categories of ID that are missed in the validator, such as Taiwanese nationals without household registration. The second digit of their ID is a letter - full format here in Chinese: https://www.immigration.gov.tw/media/20493/%E5%A4%96%E4%BE%86%E4%BA%BA%E5%8F%A3%E7%B5%B1%E4%B8%80%E8%AD%89%E8%99%9F%E7%B7%A8%E7%A2%BC%E5%8E%9F%E5%89%87.pdf

Comments

Edditoria

Hi, Thanks for your suggestion. I did a little search about this issue. Is it the Resident Certificate ID Number, rather than National Identification Card? May I know how is the use case? I'm considering that: 1. validate both type of ID by default, an optional "strict" mode to validate TWID only, e.g. `validid.twid(id, 'strict')`. 1. validate TWID by default, an optional "???" mode to validate more type of identities, e.g. `validid.twid(id, 'any')`. Or, 1. simply `if (validid.twid(id, 'twid') or validid.twrcid()) {}`. Thanks. p.s. Even more information: [居留證統一證號編碼擬比照身分證 估百萬人受惠](https://www.cna.com.tw/news/firstnews/201810280104.aspx) (Resident Certificate ID numbering system will match with National Identification ID format)

fifieldt

Hi, Thanks for your detailed investigation. Use case 1 is what I would aim for, as according to the government, all of these types of IDs are "Uniform ID Numbers" (統一證號) and are able to be used in all the same circumstances (they're the IDs used on drivers licenses, national health insurance cards, labor insurance, labor pension account, bank accounts etc). For your interest here are the details. Welcome to the complicated world of Taiwan IDs! So, for odd legal reasons Taiwan lacks the concept of "Citizens", which is present in most countries. Instead, it has "Nationals". "Nationals" are basically what anyone reasonable would consider Taiwanese Citizens - they have a Taiwan passport, the right to live in Taiwan, and have an obligation for military service. However, there are two types of Nationals - Nationals with Household Registration and Nationals without Household Registration. Nationals with Household Registration have a Uniform ID Number 統一證號 on a National Identification Card 身分證. Nationals without Household Registration have a Uniform ID Number 統一證號 on a Taiwan Area Resident Certificate 台灣地區居留證. Foreign nationals resident in Taiwan have a Uniform ID Number 統一證號 on an Alien Resident Certificate 統一證號. There's also a special case for people from Hong Kong, Macao and China, but it's essentially equivalent to the foreign national case. Back to use cases - in practice, what happens is that any government website will accept any of those Uniform ID Numbers 統一證號, since they tend to know about all the corner cases. However, commercial websites often unintentionally end up erroneously rejecting some of the valid IDs, usually because they've written code which only handles the common (National Identification Card 身分證) case. Or, use a library that does the same ;) The government actually actively contacts commercial entities to get them to fix the problem, but it's an uphill battle - which is why they're considering changing the ID format of the corner cases to match the National Identification Card 身分證. However, until then, I thought it might be worth trying to update the validid library :)

fifieldt

Present for you - some test data in #4 . I know it's not properly alphabetized, and you might need to change the logic or method names, but hope it will be useful to you :)

Edditoria

Have followed up and version up! New card type is introduced as "twrc" (Usage: `validid.twrc(id)`) You can `if (validid.twid(id) || validid.twrc(id)) { doSomething(); }` or whatever you want. Many thanks!