koblas / stdnum-js

A JavaScript library to provide functions to handle, parse and validate standard numbers.
MIT License
38 stars 26 forks source link

Swedish person number - checksum incorrect when value is 13 in length #93

Closed teebu closed 1 year ago

teebu commented 1 year ago

value: 11900102-2384

online validator: https://swedish.identityinfo.net/personalidentitynumber/validate?number=11900102-2384

Other then the - not being a + because its over 100 years i dont see this being a problem.

https://en.wikipedia.org/wiki/Personal_identity_number_(Sweden) -> For 12-digit numbers, the two first digits are omitted from the calculation.

check: remove first 2 digits if its 13 in length, and luhn value should be 4, which is correct.

9001022384

looks like your code checks the entire digits 119001022384