Closed teebu closed 12 months ago
Yes, it does look like a consistent bug I dropped into a lot of places.
Thanks for continuing to find them!
Since this value represents a birthday, what do you think about adding future date invalidation?
The code is already doing that. :)
function checkBirthdate(value: string) {
// eslint-disable-next-line prefer-const
let [dd, mm, yy, rest] = strings
.splitAt(value, 2, 4, 6, 9)
.map(v => parseInt(v, 10));
// Correct the birth day for D-numbers. These have a modified first digit.
// https://no.wikipedia.org/wiki/F%C3%B8dselsnummer#D-nummer
if (dd > 40) {
dd -= 40;
}
....
What I meant is if the value is representing a DOB greater then today's date, not D or H number. Something like adding a param to isValidDate()
that checks if its a future date.
https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
if the remainder is 0 and you end up with 11 − 0, the check digit is 0, and not 11.
This seems to be a pretty common issue with other validators too.
values: 11111598403, 23114048690
should be valid