https://github.com/uphold/ssn-validator
Validate and mask a U.S. Social Security Number (SSN)
https://github.com/uphold/ssn-validator
Last synced: 6 months ago
JSON representation
Validate and mask a U.S. Social Security Number (SSN)
- Host: GitHub
- URL: https://github.com/uphold/ssn-validator
- Owner: uphold
- License: mit
- Created: 2016-02-05T11:38:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T20:11:15.000Z (almost 2 years ago)
- Last Synced: 2024-11-11T18:56:57.021Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 169 KB
- Stars: 12
- Watchers: 57
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ssn-validator
Validate and mask a U.S. Social Security Number (SSN).## Status
[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url]## Installation
Install the package via `npm`:```sh
npm install ssn-validator --save
```## Usage
### `isValid(value)`
This method validates if the given value is a valid `Social Security Number`.#### Arguments
1. `value` _(*)_: The value to validate.#### Returns
_(boolean)_: Returns whether the input value is a valid SSN or not.#### Example
```js
isValid({});
// => falseisValid('0-1-1234567');
// => falseisValid('011-23-4567');
// => trueisValid('011234567');
// => true
```--------------------------------------------------------------------------------
### `mask(value)`
This method will help you protect this sensitive piece of information by obfuscating some digits.#### Arguments
1. `value` _(*)_: The value to mask.#### Returns
_(string)_: Returns the masked value by replacing value certain digits by 'X'.#### Example
```js
mask({});
// Throws an Error.mask('0-1-1234567');
// Throws an Error.mask('011-23-4567');
// => XXX-XX-4567mask('011234567');
// => XXXXX4567
```--------------------------------------------------------------------------------
## Tests
To test using a local installation of `node.js`:```sh
npm test
```## Release
```sh
npm version [ | major | minor | patch] -m "Release %s"
```## License
MIT[npm-image]: https://img.shields.io/npm/v/ssn-validator.svg?style=flat-square
[npm-url]: https://npmjs.org/package/ssn-validator
[travis-image]: https://img.shields.io/travis/uphold/ssn-validator.svg?style=flat-square
[travis-url]: https://img.shields.io/travis/uphold/ssn-validator.svg?style=flat-square