norwegian-national-id-validator
- NorwegianId
- diffYears
- getGender
- idNumberContainsBirthDate
- isValidCheckDigits
- isValidDate
- possibleAgeOfPersonWithIdNumber
- possibleAgesOfPersonWithIdNumber
- validateNorwegianIdNumber
- possibleBirthDateOfIdNumber
▸ Const
NorwegianId(idNumber
): Object
Object-oriented API for Norwegian National ID Validator
example
import { NorwegianId } from 'norwegian-national-id-validator';
const valid = NorwegianId('0000000000');
Name | Type | Description |
---|---|---|
idNumber |
string |
norwegian social security number |
Object
Name | Type |
---|---|
age |
() => number | undefined |
idNumber |
string |
isBirthNumber |
() => boolean |
isDNumber |
() => boolean |
isFemale |
() => boolean |
isFhNumber |
() => boolean |
isHNumber |
() => boolean |
isMale |
() => boolean |
isValid |
() => boolean |
birthDate |
() => Date | undefined |
▸ Private
diffYears(startDate
, endDate
): number
Calculated the difference betweeen two dates.
Name | Type | Description |
---|---|---|
startDate |
Date |
Date instance |
endDate |
Date |
Date instance |
number
▸ getGender(elevenDigits
): Gender
| undefined
Returns the gender based of ID number. Returns undefined
when no gender
information is available.
Name | Type | Description |
---|---|---|
elevenDigits |
string |
ID number |
Gender
| undefined
▸ idNumberContainsBirthDate(elevenDigits
): boolean
Check if idNumber contains birth date
Name | Type | Description |
---|---|---|
elevenDigits |
string |
idNumber |
boolean
▸ Private
isValidCheckDigits(elevenDigits
): boolean
Name | Type |
---|---|
elevenDigits |
string |
boolean
▸ isValidDate(date
, expectedYear
, expectedMonth
, expectedDay
): boolean
Checks if a date is valid against another
Name | Type | Description |
---|---|---|
date |
Date |
Date instance |
expectedYear |
string |
|
expectedMonth |
string |
|
expectedDay |
string |
boolean
▸ possibleAgeOfPersonWithIdNumber(elevenDigits
): number
| undefined
Returns the age of a person with given Norwegian national identity number.
Returns undefined
when birth date could not be determined (e.g. for FH-numbers and invalid ID-numbers).
Name | Type | Description |
---|---|---|
elevenDigits |
string |
Identification number |
number
| undefined
▸ possibleAgesOfPersonWithIdNumber(elevenDigits
): number
[]
Find possible age of person based of ID number
Name | Type | Description |
---|---|---|
elevenDigits |
string |
Identification number |
number
[]
▸ validateNorwegianIdNumber(idNumber
): boolean
Checks if the given value is a valid Norwegian national identity number.
example
import { validateNorwegianIdNumber } from 'norwegian-national-id-validator';
const valid = validateNorwegianIdNumber(0000000000);
Name | Type | Description |
---|---|---|
idNumber |
string |
social security number |
boolean
true
for valid, and false
for invalid ID number.
▸ possibleBirthDateOfIdNumber(elevenDigits
): Date
| undefined
Returns the birth date of a person with the given Norwegian national identity number as Date object. Returns undefined
when birth date could not be determined (e.g. for FH-numbers and invalid ID-numbers).
Name | Type | Description |
---|---|---|
elevenDigits |
string |
Identification number |
Date
| undefined