python-stdnum
python-stdnum copied to clipboard
Incorrect validation results for Chinese ID cards, some specific area codes cannot pass validation
For ID card numbers starting with 412723, they are indeed valid in reality, but this library considers them invalid. This area code is no longer in use due to some administrative adjustments, but people born before the change still have ID numbers starting with this code. Therefore, there are still a large number of people with ID numbers starting with this code.
Example: This official announcement clearly shows many ID numbers starting with this code (http://zrzyhghj.xuchang.gov.cn/xxgg/013002/20190822/b1eab7b9-b5d1-4405-83bc-c32cc0ace220.html)
Thanks for reporting this. Do you know if there is a list of historic area codes that are considered valid? The list of locations is currently taken from https://github.com/cn/GB2260 I can't read Chinese so I read things via Google Translate which is far from ideal.
Validating the location part of the number is really nice because it greatly limits the numbers that are considered valid. If there are just a handful of old area codes I can add them to a separate list but if there are many the location verification should probably become optional.
The following wikipedia pages seem to contain a list that includes all codes since the inception of the GB/T 2260 standard in 1980, including deprecated codes. It also indicates the year of adoption and deprecation of each code.
- zone 1: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (1区)
- zone 2: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (2区)
- zone 3: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (3区)
- zone 4: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (4区)
- zone 5: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (5区)
- zone 6: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (6区)
- zone 7: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (7区)
- zone 8: https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码 (8区)
Hi @lucasicr,
Thanks for providing the links. In 0e64cf6 I've updated the download script to download the information from Wikipedia instead and I've also updated the check to take the birth year into account when checking the birth location.