uphold/tin-validator

Name: tin-validator

Owner: Uphold

Description: Validate and mask a U.S. Taxpayer Identification Number (TIN)

Created: 2015-10-07 09:37:38.0

Updated: 2017-07-18 17:15:01.0

Pushed: 2017-07-23 12:28:47.0

Homepage:

Size: 21

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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

npm version build status

Installation

Install the package via npm:

install tin-validator --save
Usage
isValid(value)

This method validates if the given value is a valid Taxpayer Identification Number.

Arguments
  1. value (*): The value to validate.
Returns

(boolean): Returns whether the input value is a valid TIN or not.

Example
lid({});
> false

lid('9-0-0700000');
> false

lid('900-70-0000');
> true

lid('900700000');
> 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
({});
hrows an Error.

('9-0-0700000');
hrows an Error.

('900-70-0000');
> XXX-XX-0000

('900700000');
> XXXXX0000

sanitize(value)

This method will remove all non numeric characters from the value.

Arguments
  1. value (*): The value to sanitize.
Returns

(string): Returns the sanitized value containing only numeric characters.

Example
tize('9-0 0700000');
> 900700000

tize('900a7#$0foobar0000');
> 900700000

Tests

To test using a local installation of node.js:

test

To test using Docker exclusively:

er-compose run --rm sut
Release
version [<newversion> | major | minor | patch] -m "Release %s"
License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.