diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index b8fedc4536dc2bb79a26abfab7e188b8f60d0df2..746d2a286bac0a624db8fe6f84b04b75ca1e95c8 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -240,11 +240,26 @@ export function isFemaleBasedOnNationalId(nationalId: string): boolean { return parseInt(nationalId.charAt(8), 10) % 2 === 0 } +/** + * The ID-number format is scheduled to change in the future: + * https://www.skatteetaten.no/deling/opplysninger/folkeregisteropplysninger/pid/ + * + * Do not attempt a suggestion if we are at the time when the format will change. + */ +function shouldAttemptSuggestion(): boolean { + const currentYear = getYear(new Date()) + + // Keeping it simple, if this code is still running and should be revised. + // The new numbers are scheduled to appear in 2032 + return currentYear <= 2031 +} + export function extractGenderOrBlank(nationalId?: string): string { if ( nationalId == null || nationalId === '' || - isValidFnr(nationalId) !== true + isValidFnr(nationalId) !== true || + !shouldAttemptSuggestion() ) { return '' } @@ -300,7 +315,8 @@ export function extractBirthdateFromNationalId( if ( nationalId == null || nationalId === '' || - isValidFnr(nationalId) !== true + isValidFnr(nationalId) !== true || + !shouldAttemptSuggestion() ) { return null }