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

Swdeden personalidentitynumber - format acceptance and age validations

Open teebu opened this issue 2 years ago • 2 comments

https://swedish.identityinfo.net/personalidentitynumber

The format states the [-+] are optional.

  • 11900102-2384 -> invalid because it needs + to indicate over 100 years of age, also im thinking 1800 should be a cutoff. 119001022384 would also be an acceptable format, but not pass due to 1800 cutoff (1190 is YYYY)
  • 5505260017 -> valid because - is optional
  • 198902255630 -> valid because - is optional
  • 19781204+0009 -> invalid because + indicates age is over 100 years
  • 19200102-0755 -> invalid because - indicates the age is under 100 years

teebu avatar Jan 03 '24 17:01 teebu

I wonder if the - and + gets assigned only once during creation, and gets updated after a person turns 100 to make it accurate after they roll over 100 mark. I bet that doesn't happen often, most people don't live that long. 🤔

What happens to old records that were accurate at the time of entry with - but not today, as many years have passed and rolled them over 100 mark.

Probably explains why they are optional and use full year.

teebu avatar Jan 10 '24 17:01 teebu

I've been working on this... It makes sense to "fix" the year to 4 digits and perform all validation after that. Not "stress" over the +- difference for the long form version.

koblas avatar Jan 10 '24 18:01 koblas