Skip to content

Validate and generate danish social security numbers (cpr-nummer)

License

Notifications You must be signed in to change notification settings

mathiasvr/danish-ssn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Danish SSN (CPR) npm

Validate and generate danish social security numbers (cpr-nummer)

install

$ npm install danish-ssn

usage

Validation is based on modulo-11 and century spans described in this document (in danish).

var cpr = require('danish-ssn')

console.log(cpr('061093-7438'))

cpr(cpr)

Retrieve information contained by the cpr number, in the following format:

{ cpr: '0610937438',
  valid: true,
  date: new Date('1893-10-06T00:00:00.000Z'),
  sex: 'Female' }

.isValid(cpr)

Returns whether or not the cpr number is valid*.

.validate(cpr)

Makes a cpr number valid by correcting the check digit. Returns null if the cpr has no valid check digit.

.validForDate(date)

Generates a list of all valid* cpr numbers for a given date.

*Note that since 2007, CPR numbers with invalid check digits has been issued for birthdays on January 1.

license

MIT

About

Validate and generate danish social security numbers (cpr-nummer)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published