Closed danielstalenbring closed 3 years ago
@danielstalenbring – Yes, completely true. You're right that that's a bad assumption nowadays. Will look into a fix.
@danielstalenbring I've looked into the issue; and sadly you can never extract the century from a 10-digit number, unless you have the correct hyphen to start with ("-" = younger than 100 years, "+" = older than 100 years). The Luhn-algorithm/sum check only looks at the 10 digit variant.
The only "improvement" we can do here is to assume that the user is always under 100 years old if no hyphen is supplied.
Agree, it's a tricky situation. But I guess you have to assume that the correct hyphen is used, even though most people don't know about + :)
It was time for a rewrite anyway 🙂, released a new package; olssonm/swedish-entity that will replace this one.
Please look into it – should solve your issue here too.
The IdentityNumberFormatter adds 19 before all 10 number PINs, meaning if you're born in 2002, it would mistakenly be formatted as 1902. This only applies if you provide a 10 digit PIN and want it formatted as 12 digits.