File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -122,18 +122,18 @@ export function validateNationalIdentityNumber(
122122 // copy/inspiration from NAV https://github.com/navikt/fnrvalidator/blob/77e57f0bc8e3570ddc2f0a94558c58d0f7259fe0/src/validator.ts#L108
123123 let year = Number ( value . substring ( 0 , 2 + add ) ) ;
124124 const month = Number ( value . substring ( 2 + add , 4 + add ) ) ;
125- const day = Number ( value . substring ( 4 + add , 6 + add ) ) ;
125+ let day = Number ( value . substring ( 4 + add , 6 + add ) ) ;
126126
127127 // 1900 isn't a leap year, but 2000 is. Since JS two digits years to the Date constructor is an offset from the year 1900
128128 // we need to special handle that case. For other cases it doesn't really matter if the year is 1925 or 2025.
129129 if ( year === 0 ) {
130130 year = 2000 ;
131131 }
132132
133- // for a d-number the day is increased by 40 . Eg the 31st of a month would be 71 , or the 3rd would be 43 .
134- // thus we need to subtract 40 to get the correct day of the month
135- if ( day > 40 ) {
136- day = day - 40 ;
133+ // for a samordningsnummer the day is increased by 60 . Eg the 31st of a month would be 91 , or the 3rd would be 63 .
134+ // thus we need to subtract 60 to get the correct day of the month
135+ if ( day > 60 ) {
136+ day = day - 60 ;
137137 }
138138
139139 return isValidDate ( year , month , day ) ;
You can’t perform that action at this time.
0 commit comments