Closed MiniGod closed 1 week ago
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.
isPerson
<= 31
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
Interesting. Not a bad idea to validate the months.
This has been implemented on the v2 branch, you can try yarn add kennitala@2.0.0-beta.0 to test it out.
yarn add kennitala@2.0.0-beta.0
Available in V2.0.2 now non-beta.
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:
Related to #16