arokor / pernr

Validation functions for Swedish national identification numbers
MIT License
3 stars 1 forks source link

Does not support coordination numbers (a.k.a samordningsnummer) #1

Closed buren closed 7 years ago

buren commented 7 years ago

This lib does unfortunately not support coordination number (a.k.a samordningsnummer, a.k.a "temporary personnummer"), causing false negatives for valid inputs.

Coordination numbers have 60 added to the day, see https://sv.wikipedia.org/wiki/Samordningsnummer.

Test case that can be added to test/persnr.test.js:

it('should classify valid coordination numbers (a.k.a samordningsnummer) as valid', function(){
  expect((new Pernr('010161-4389')).isValid()).to.equal(true);
  expect((new Pernr('010161-4405')).isValid()).to.equal(true);
  expect((new Pernr('010161-4421')).isValid()).to.equal(true);
});
arokor commented 7 years ago

Good point. We should add this functionality.

2 aug. 2017 kl. 13:20 skrev Jacob Burenstam notifications@github.com:

This lib does unfortunately not support coordination number (a.k.a samordningsnummer, a.k.a "temporary personnummer"), causing false negatives for valid inputs.

Coordination numbers have 60 added to the day, see https://sv.wikipedia.org/wiki/Samordningsnummer.

Test case that can be added to test/persnr.test.js:

it('should classify valid coordination numbers (a.k.a samordningsnummer) as valid', function(){ expect((new Pernr('010161-4389')).isValid()).to.equal(true); expect((new Pernr('010161-4405')).isValid()).to.equal(true); expect((new Pernr('010161-4421')).isValid()).to.equal(true); }); โ€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

arokor commented 7 years ago

merged and npm published

buren commented 7 years ago

Awesome @arokor ๐Ÿ‘

karlpokus commented 7 years ago

@arokor Great that you added support for samordningsnummer! I see that this issue is closed but thought I should ask: how about reservnummer and skyddad identitet?

buren commented 7 years ago

For "skyddad identitet" it seems like you're given a new, valid, "personnummer". See https://sv.wikipedia.org/wiki/Skyddad_identitet.

I had no idea that "Reservnummer" even existed ๐Ÿ˜… certainly makes it an interesting edge case in terms of a library like this. After reading through https://sv.wikipedia.org/wiki/Reservnummer there seems to be no formalized standard just a few recommendations.

In https://sv.wikipedia.org/wiki/Reservnummer#Format they write:

Socialstyrelsen hittade tre olika varianter av reservnummer i patientregistret fรถr 2008 [...] [Roughly translated to] Socialstyrelsen found three variants of "reservnummer" i the patient registry for 2008 [...]

So it seems like there is really no, stable, way of validating that.

Perhaps just mentioning those two cases in the README could reasonable.

karlpokus commented 7 years ago

no, stable, way of validating [reservnummer]/.../Perhaps just mentioning those two cases in the README could reasonable.

Yeah. That might be nice.

You could be right regarding skyddad identitet although I seem to remember seeing a wierd format on a patient chart like SKYDDAD-IDENTITET-XXXX although that might be post-processing. Nevermind.

arokor commented 7 years ago

Interesting. I had no idea that "reservnummer" existed. Since by definition a reservnummer isn't a valid personnummer they should be validated as invalid. We could add an isReservnummer method though that would return true if the first 6 chars is a valid date and any of the last 4 chars contain a character which would detect most reservnummer cases but probably not all

buren commented 7 years ago

Added this to the README of a Ruby implementation that I've contributed to before: https://github.com/c7/personnummer#note-on-reservnummer.

Seemed like the "best" approach. The risk of implementing isReservnummer is that people might think/believe/hope that it handles all cases (which is clearly impossible, since there are only guidelines/recommendations for the format and no requirements).

arokor commented 7 years ago

That makes sense. Let's add a note to the readme. Do you want to do it or should I?

buren commented 6 years ago

@arokor, @karlpokus added note to README https://github.com/arokor/pernr/pull/3