diff --git a/kennitala/__init__.py b/kennitala/__init__.py index 34a61e9..c78bea1 100644 --- a/kennitala/__init__.py +++ b/kennitala/__init__.py @@ -140,6 +140,11 @@ def validate(self): try: date(year, month, day) + except ValueError: + if int(kennitala[0]) <= 3 or 1 > day > 31: + return False + + try: checkdigit = Kennitala._compute_checkdigit(kennitala) return kennitala[-2] == checkdigit except ValueError: diff --git a/tests/test_kennitala.py b/tests/test_kennitala.py index 8194d14..43c1d0f 100644 --- a/tests/test_kennitala.py +++ b/tests/test_kennitala.py @@ -9,6 +9,7 @@ '140543-3229', # kennitala of Icelandic president '1203753509', # kennitala of Icelandic prime minister '6503760649', # kennitala of Þjóðskrá Íslands (Registry Iceland) + '7102692709', # kennitala of Þjóðleikhúsið (National Theatre) ) birth_dates = (date(1943, 5, 14), date(1975, 3, 12))