GithubHelp home page GithubHelp logo

dendisuhubdy / tin-validator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uphold/tin-validator

0.0 1.0 0.0 21 KB

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

JavaScript 100.00%

tin-validator's Introduction

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:

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

isValid({});
// => false

isValid('9-0-0700000');
// => false

isValid('900-70-0000');
// => true

isValid('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

mask({});
// Throws an Error.

mask('9-0-0700000');
// Throws an Error.

mask('900-70-0000');
// => XXX-XX-0000

mask('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

sanitize('9-0 0700000');
// => 900700000

sanitize('900a7#$0foobar0000');
// => 900700000

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] -m "Release %s"

License

MIT

tin-validator's People

Contributors

ruimarinho avatar ruipenso avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.