se-ssn
v2.1.1
Published
Validation for Swedish style social security numbers (ssn/personnummer)
Downloads
473
Readme
se-ssn
Validation for Swedish style organization numbers (organisationsnummer).
The validation checks that the first 6 chars are a representation of a valid date from the last 100 years (this behaviour can be configured, see Getting started) and that char 10 is a valid control digit based on the other characters.
Getting started
The library is available as an npm package. To install the package run:
npm install se-ssn --save
Use like this:
import {isValidSsn} from 'se-ssn'
isValidSsn('8101013608')
//=> true
isValidSsn('foo')
//=> false
// Optionally validate that a ssn is for a person of at least a certain age
isValidSsn('8101013608', {minYears: 80})
//=> false
If you are in a multinational context you can use the alias isValidSwedishSsn for clarity:
import {isValidSwedishSsn} from 'se-ssn'
isValidSwedishSsn('8101013608')
//=> true
Alternatively with CommonJS:
var seSsn = require("se-ssn")
seSsn.isValidSsn('8101013608')
//=> true
Legacy support
IE8 is not supported.
License
MIT.