Kennitala icon indicating copy to clipboard operation
Kennitala copied to clipboard

Invalid date is accepted as valid kennitala

Open MiniGod opened this issue 3 years ago • 2 comments

The isPerson validation does not account for invalid dates. I see the current code simply checks that the day is <= 31, but 310222 for instance is not a valid date, and hence not a valid kennitala.

Would have to parse the date and validate it.

One way to do it:

const isValid = isNaN(new Date('2022-02-31').getTime())

Related to #16

MiniGod avatar Jan 31 '22 12:01 MiniGod

Interesting. Not a bad idea to validate the months.

HermannBjorgvin avatar Jan 31 '22 14:01 HermannBjorgvin

This has been implemented on the v2 branch, you can try yarn add [email protected] to test it out.

HermannBjorgvin avatar Apr 06 '22 15:04 HermannBjorgvin