Skip to content

Validation issue #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nnew2 opened this issue May 15, 2019 · 8 comments
Closed

Validation issue #5

nnew2 opened this issue May 15, 2019 · 8 comments

Comments

@nnew2
Copy link

nnew2 commented May 15, 2019

Hello,

It seems that there are issues in the validation process, as for an example the below returns True

`from personnummer import personnummer

print personnummer.valid('MASKED')`

pip show personnummer
Name: personnummer
Version: 1.0.2
Summary: Validate Swedish social security numbers
Home-page: http://github.com/personnummer/python
License: MIT
Location: /Library/Python/2.7/site-packages
Requires:
Required-by:

@nnew2
Copy link
Author

nnew2 commented May 15, 2019

Due to sensitive information MASKED was sent to the repo owner in private.

@Johannestegner
Copy link
Member

Hi there!

The code currently validate both "personnummer" and "samordningsnummer" which is a temporary type of personnummer used for none-permanent residents in Sweden.
We have been discussing if we should make this a flag (or rather, making turning it of a flag), but haven't decided yet.

The "samordningsnummer" works as this:

The first four digits (year(2), month(2)) is the same as with a standard personnummer, but the day have 60 added to it. So if it is between 61 and 91, it's a samordningsnummer.

Is your requirement that the code ONLY take personnummer or are samordningsnummer a legal value too?

@nnew2
Copy link
Author

nnew2 commented May 16, 2019

The value that passed the validity test starts with 07077676XX, i.e. Swedish mobile number.
Not sure if that would go under "samordningsnummer" ?

If parsed as an (int) then I presume the leading 0 would be removed leaving us with 7077676XX but still don't see how it would return as valid.

@Johannestegner
Copy link
Member

070776-xxxx would parse as someone born 2017 07 16 and then depending on the last 4 digits, it may or may not be validated by the lunh algorithm. If you use a integer value, it will treat it as 07 yes.

@nnew2
Copy link
Author

nnew2 commented May 16, 2019

Thanks for the clarification.

But how can 070776 be parsed as 2017-07-16? Shouldn't that parse as 2007-07-76?

@Johannestegner
Copy link
Member

Sorry, not 2017, 2007 of course, hehe.
The check we do to validate the "date of birth" is basically to check if it is a valid date and if it is not, we try it with -60 on the days to generate a valid day instead of the samordnings addition to the date. So 76 would be seen as 16 in the date test. That means that any value within the ranges of 1-31 and 61-91 (as long as it is a 31 day long month) is a valid number for the day part of the date.

@nnew2
Copy link
Author

nnew2 commented May 16, 2019

Ok, I see.

So this was pretty much a coincidence that the last four digits passed the lunh alg as well.
Regarding your discussion to add a flag to exclude samordningsnummer, I think that would be a good addition.

@frozzare
Copy link
Member

Added flag to exclude samordningsnummer. Not released a new version yet.
e99cfd5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants