Skip to content

Latest commit

 

History

History
77 lines (47 loc) · 1.7 KB

README.md

File metadata and controls

77 lines (47 loc) · 1.7 KB

Global SSN Validator

MIT Licensed

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 

Installation

Install the package via npm:

npm install @fossbarrow/[email protected] --save

Usage

ssnIsValid(value)

This method validates if the given value is a valid Social Security Number.

Input

string matching 10 or 12 words in length. Dashes and colons are ignored to the length count.


mask(value)

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.

Example

ssnMask({});
// => Throws an Error.

ssnMask('900211-1234')
// => XXXX11XX3X

ssnMask('19900211-1234')
// => XXXXXX11XX3X

ssnMask('12345678912');
// => Throws an Error.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Feel free to add a pull-request containing changes to the validator, making it more accurate and/or faster!

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.