Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ein-validator with all npm packages installed. Try it out:

var einValidator = require("ein-validator")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ein-validator v1.0.0

Employer Identification Number validator and masker

ein-validator

Validate and mask a U.S. Employer Identification Number (EIN).

Status

npm version build status

Installation

Install the package via npm:

npm install ein-validator --save

Usage

isValid(value)

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

Arguments

  1. value _(*)_: The value to validate.

Returns

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

Example

isValid({});
// => false

isValid('0112345-67');
// => false

isValid('01-1234567');
// => true

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

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

mask('0112345-67');
// Throws an Error.

mask('01-1234567');
// => XX-XXX0000

mask('011234567');
// => XXXXX4567

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free