Skip to content

Mr1BitL8r/swedish-ssn-validator

 
 

Repository files navigation

Global SSN Validator

MIT Licensed

Validate and mask functionality for an Swedish Social Security Number (SSN).

Installation

Install the package via npm:

npm install @fossbarrow/swedish-ssn-validator@1.0.0 --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.

Example

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

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.

About

[npm package] - Validator for Swedish SSN's

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%