Incorrect validation of month
Closed this issue · 3 comments
Hello,
I have noticed that in version 2.0.34 there was added month and day validation.
Unfortunately, it does not take into account the fact that in PESEL there is a century encoded in the month digits.
Basically, there is a possibility that month digits > 12, for all people born after 2000.
Example: PESEL 00320506835 returns false.
See https://en.wikipedia.org/wiki/PESEL for the algo.
Other than that - great job, thanks.
Thanks, according to wikipedia only possibilities are:
for other birthdates:
2000–2099 – month field number is increased by 20
2100–2199 – month + 40
2200–2299 – month + 60
1800–1899 – month + 80
I will change validation of month to only prevent values like: 13-19, 33-39, 53-59, 73-79, 93-99 which I believe are not valid.
Released version 2.0.40.
I've added some pesels generated for people from other centuries to tests (both wrong and correct) and my tests have passed, so I believe this should fix the issue:
https://github.com/radarsu/validate-polish/blob/master/src/index.ts#L25
Let me know if updating to 2.0.40 fixes issues for you.
As far as I am testing, it looks good!
Thanks for the extremely quick fix <3