Validate and mask functionality for an Swedish Social Security Number (SSN).
Install the package via npm
:
npm install @fossbarrow/swedish-ssn-validator@1.0.0 --save
This method validates if the given value is a valid Social Security Number
.
string matching 10 or 12 words in length. Dashes and colons are ignored to the length count.
ssnIsValid({});
// => false
ssnIsValid('011-23-4567');
// => false
ssnIsValid('011234567');
// => false
ssnIsValid('1990-11-21:1234');
// => True
ssnIsValid('199011211234');
// => True
ssnIsValid('9011211234');
// => True
ssnIsValid('90-11-21:1234');
// => True
This method will help you protect the SSN from sensitive information by obfuscating some digits.
The ssn key for day of birth and gender is left unmasked.
ssnMask({});
// => Throws an Error.
ssnMask('900211-1234')
// => XXXX11XX3X
ssnMask('19900211-1234')
// => XXXXXX11XX3X
ssnMask('12345678912');
// => Throws an Error.
Please see CHANGELOG for more information on what has changed recently.
Feel free to add a pull-request containing changes to the validator, making it more accurate and/or faster!
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.