Validate and mask functionality for an Swedish Social Security Number (SSN).
Example
ssnIsValid('1990-11-21:1234');
// => True
ssnMask('19900211-1234') // The ssn key for _day of birth_ and _gender_ is left unmasked.
// => XXXXXX11XX3X
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.
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.