Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tin-validator

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tin-validator

Taxpayer Identification Number validator and masker

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.1K
increased by6.24%
Maintainers
1
Weekly downloads
 
Created
Source

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

License

MIT

Keywords

FAQs

Package last updated on 07 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc