Validate Norwegian national identity numbers (birth number (fødselsnummer), D-number, H-number and FH-number).
The NPM module is ES5, but TypeScript and Flow types is also exported. Types for Flow is generated with Flowgen.
Install the package via npm
:
npm install --save norwegian-national-id-validator
or
yarn add norwegian-national-id-validator
This function checks if the given value is a valid Norwegian national identity number. Returns true
for valid, and false
for invalid ID-number.
Examples
import { validateNorwegianIdNumber } from 'norwegian-national-id-validator'
validateNorwegianIdNumber('29029900157')
// => false
validateNorwegianIdNumber('29029600013')
// => true
This function 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).
Examples
import { possibleAgeOfPersonWithIdNumber } from 'norwegian-national-id-validator'
possibleAgeOfPersonWithIdNumber('03111590925')
// => 1
possibleAgeOfPersonWithIdNumber('03110175225')
// => 15
To run the tests for this module:
npm test