Closed balderman1 closed 4 years ago
Thanks for pointing this out. The is_valid()
function should indeed never raise an exception (similarly validate()
should only raise subclasses of ValidationError
).
Just to confirm: 19670-19-9535 only has 11 digits so should not be considered valid, can you confirm?
Confirmed Thanks
On Wed, Feb 12, 2020, 8:59 PM Arthur de Jong notifications@github.com wrote:
Thanks for pointing this out. The is_valid() function should indeed never raise an exception (similarly validate() should only raise subclasses of ValidationError).
Just to confirm: 19670-19-9535 only has 11 digits so should not be considered valid, can you confirm?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arthurdejong/python-stdnum/issues/188?email_source=notifications&email_token=ADCIPWPYDLXDWF4CDEPWYFDRCRBIPA5CNFSM4KTWFUJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELR7DZQ#issuecomment-585363942, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCIPWILYVACA4C22J5I7OTRCRBIPANCNFSM4KTWFUJQ .
Thanks!
I have code that calls the is_valid method of stdnum.se.personnummer. The input I am sending is “breaking” the birthday calculation and I believe should be fixed. The code below reproduces the issue
The output is:
Traceback (most recent call last): File "C:/dev/projects/waf-ai-repo/reproduce_stdnum_issue.py", line 3, in
is_valid('19670-19-9535')
File "C:\dev\tools\python371\lib\site-packages\stdnum\se\personnummer.py", line 118, in is_valid
return bool(validate(number))
File "C:\dev\tools\python371\lib\site-packages\stdnum\se\personnummer.py", line 110, in validate
get_birth_date(number)
File "C:\dev\tools\python371\lib\site-packages\stdnum\se\personnummer.py", line 73, in get_birth_date
month = int(number[4:6])
ValueError: invalid literal for int() with base 10: '0-'