python-stdnum icon indicating copy to clipboard operation
python-stdnum copied to clipboard

Incorrect validation results for Chinese ID cards, some specific area codes cannot pass validation

Open moe001 opened this issue 1 year ago • 1 comments

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)

moe001 avatar Jun 04 '24 03:06 moe001

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.

arthurdejong avatar Jun 23 '24 12:06 arthurdejong

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.

arthurdejong avatar May 25 '25 20:05 arthurdejong