tin-validator
Validate and mask a U.S. Taxpayer Identification Number (TIN). A TIN may be an Employer Identification Number (EIN), an Individual Taxpayer Identification Number (ITIN) or a Social Security number (SSN).
Status
Installation
Install the package via npm
:
npm install tin-validator --save
Usage
isValid(value)
This method validates if the given value is a valid Taxpayer Identification Number
.
Arguments
value
(*): The value to validate.
Returns
(boolean): Returns whether the input value is a valid TIN or not.
Example
isValid({});
isValid('9-0-0700000');
isValid('900-70-0000');
isValid('900700000');
mask(value)
This method will help you protect this sensitive piece of information by obfuscating some digits.
Arguments
value
(*): The value to mask.
Returns
(string): Returns the masked value by replacing value certain digits by 'X'.
Example
mask({});
mask('9-0-0700000');
mask('900-70-0000');
mask('900700000');
sanitize(value)
This method will remove all non numeric characters from the value.
Arguments
value
(*): The value to sanitize.
Returns
(string): Returns the sanitized value containing only numeric characters.
Example
sanitize('9-0 0700000');
sanitize('900a7#$0foobar0000');
Tests
To test using a local installation of node.js
:
npm test
To test using Docker exclusively:
docker-compose run --rm sut
Release
npm version [<newversion> | major | minor | patch] --message "Release %s"
License
MIT