-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update algorithm to accept formatted and non formatted numbers
- Loading branch information
Francisco Cardoso
authored and
Rui Marinho
committed
Apr 13, 2016
1 parent
566768d
commit e9ed0bd
Showing
11 changed files
with
182 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extends: seegno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
plugins: | ||
- 'jscs-config-seegno' | ||
|
||
preset: seegno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
language: node_js | ||
language: bash | ||
|
||
node_js: | ||
- 4 | ||
script: | ||
- docker-compose run --rm sut | ||
|
||
services: | ||
- docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# Changelog | ||
|
||
## [0.0.2](https://github.com/seegno/is-valid-ein/tree/0.0.2) (2016-02-17) | ||
[Full Changelog](https://github.com/seegno/is-valid-ein/compare/0.0.1...0.0.2) | ||
## [0.0.2](https://github.com/seegno/ein-validator/tree/0.0.2) (2016-02-17) | ||
[Full Changelog](https://github.com/seegno/ein-validator/compare/0.0.1...0.0.2) | ||
|
||
**Merged pull requests:** | ||
|
||
- Update `es2015-node4` to `es2015` [\#3](https://github.com/seegno/is-valid-ein/pull/3) ([ruipenso](https://github.com/ruipenso)) | ||
- Update `es2015-node4` to `es2015` [\#3](https://github.com/seegno/ein-validator/pull/3) ([ruipenso](https://github.com/ruipenso)) | ||
|
||
## [0.0.1](https://github.com/seegno/is-valid-ein/tree/0.0.1) (2016-02-05) | ||
## [0.0.1](https://github.com/seegno/ein-validator/tree/0.0.1) (2016-02-05) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,94 @@ | ||
# Employer Identification Number (EIN) | ||
# ein-validator | ||
Validate and mask a U.S. Employer Identification Number (EIN). | ||
|
||
[![npm version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
|
||
This modules allows you to check if a number is a valid. | ||
## Status | ||
[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url] | ||
|
||
## Installation | ||
Install the package via `npm`: | ||
|
||
Choose your preferred method: | ||
|
||
* npm: `npm install --save is-valid-ein` | ||
* Download: [is-valid-ein](https://github.com/seegno/is-valid-ein) | ||
```sh | ||
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. | ||
|
||
*NOTE:* The input number **must not** be formated to `xxx-xxxxxx`. | ||
#### Returns | ||
_(boolean)_: Returns whether the input value is a valid EIN or not. | ||
|
||
> Check if number is valid. | ||
#### Example | ||
|
||
```js | ||
import isValidEin from 'is-valid-ein'; | ||
isValid({}); | ||
// => false | ||
|
||
isValid('0112345-67'); | ||
// => false | ||
|
||
isValidEin('xxxxxxxxx'); | ||
isValid('01-1234567'); | ||
// => true | ||
|
||
isValid('011234567'); | ||
// => true | ||
``` | ||
|
||
> Mask the number. | ||
-------------------------------------------------------------------------------- | ||
|
||
### `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 | ||
|
||
```js | ||
import { mask } from 'is-valid-ein'; | ||
mask({}); | ||
// Throws an Error. | ||
|
||
mask('0112345-67'); | ||
// Throws an Error. | ||
|
||
mask('xxxxxxxxx'); | ||
mask('01-1234567'); | ||
// => XX-XXX0000 | ||
|
||
mask('011234567'); | ||
// => XXXXX4567 | ||
``` | ||
|
||
## Running tests | ||
-------------------------------------------------------------------------------- | ||
|
||
## Tests | ||
To test using a local installation of `node.js`: | ||
|
||
```sh | ||
npm test | ||
``` | ||
|
||
[npm-image]: https://img.shields.io/npm/v/is-valid-ein.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/is-valid-ein | ||
[travis-image]: https://img.shields.io/travis/seegno/is-valid-ein.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/seegno/is-valid-ein | ||
To test using Docker exclusively: | ||
|
||
```sh | ||
docker-compose run --rm sut | ||
``` | ||
|
||
## Release | ||
|
||
```sh | ||
npm version [<newversion> | major | minor | patch] -m "Release %s" | ||
``` | ||
|
||
## License | ||
MIT | ||
|
||
[npm-image]: https://img.shields.io/npm/v/ein-validator.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/ein-validator | ||
[travis-image]: https://img.shields.io/travis/seegno/ein-validator.svg?style=flat-square | ||
[travis-url]: https://img.shields.io/travis/seegno/ein-validator.svg?style=flat-square |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sut: | ||
image: seegno/node:4-test | ||
volumes: | ||
- .:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,59 @@ | ||
{ | ||
"name": "is-valid-ein", | ||
"name": "ein-validator", | ||
"version": "0.0.2", | ||
"description": "Validate Employer Identification Number", | ||
"main": "dist/index.js", | ||
"homepage": "https://github.com/seegno/is-valid-ein", | ||
"bugs": "https://github.com/seegno/is-valid-ein/issues", | ||
"repository": "seegno/is-valid-ein", | ||
"author": "Seegno", | ||
"license": "MIT", | ||
"description": "Employer Identification Number validator and masker", | ||
"keywords": [ | ||
"EIN", | ||
"IRS", | ||
"TIN" | ||
"TIN", | ||
"US", | ||
"USA", | ||
"identification", | ||
"taxpayer", | ||
"validator" | ||
], | ||
"options": { | ||
"mocha": "--compilers js:babel-register --recursive --require should" | ||
"homepage": "https://github.com/seegno/ein-validator", | ||
"bugs": "https://github.com/seegno/ein-validator/issues", | ||
"license": "MIT", | ||
"author": "Seegno", | ||
"main": "dist/src", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/seegno/ein-validator.git" | ||
}, | ||
"scripts": { | ||
"build": "rm -rf dist/* && babel --copy-files src/ --out-dir dist/", | ||
"changelog": "github_changelog_generator --no-issues", | ||
"changelog": "github_changelog_generator --no-issues --header-label='# Changelog' --future-release=v$npm_config_future_release && sed -i '' -e :a -e '$d;N;2,4ba' -e 'P;D' CHANGELOG.md", | ||
"coverage": "babel-node node_modules/.bin/isparta cover --report html _mocha -- $npm_package_options_mocha", | ||
"lint": "eslint src test && jscs src test", | ||
"prepublish": "npm run lint && npm test && npm run build", | ||
"test": "NODE_ENV=test mocha $npm_package_options_mocha" | ||
}, | ||
"dependencies": { | ||
"lodash": "3.10.1" | ||
"prepublish": "npm run transpile", | ||
"test": "mocha $npm_package_options_mocha", | ||
"testdocker": "docker-compose run --rm sut", | ||
"transpile": "rm -rf dist/* && babel src --out-dir dist/src", | ||
"version": "npm run changelog --future-release=$npm_package_version && npm run transpile && git add -A CHANGELOG.md dist" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.4.5", | ||
"babel-eslint": "5.0.0-beta9", | ||
"babel-preset-es2015": "6.5.0", | ||
"babel-register": "6.4.3", | ||
"coveralls": "2.11.6", | ||
"eslint": "1.8.0", | ||
"eslint-config-seegno": "2.0.0", | ||
"eslint-plugin-babel": "3.1.0", | ||
"jscs": "2.9.0", | ||
"jscs-config-seegno": "1.1.0", | ||
"mocha": "2.4.5", | ||
"should": "8.2.1" | ||
} | ||
"babel-cli": "^6.4.0", | ||
"babel-eslint": "^6.0.2", | ||
"babel-preset-es2015": "^6.5.0", | ||
"babel-register": "^6.3.13", | ||
"eslint": "^2.7.0", | ||
"eslint-config-seegno": "^4.0.0", | ||
"eslint-plugin-babel": "^3.0.0", | ||
"eslint-plugin-sort-class-members": "^1.0.1", | ||
"isparta": "^4.0.0", | ||
"jscs": "^2.11.0", | ||
"jscs-config-seegno": "^2.0.0", | ||
"mocha": "^2.3.4", | ||
"pre-commit": "^1.1.2", | ||
"should": "^8.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=0.10" | ||
}, | ||
"options": { | ||
"mocha": "--compilers js:babel-register --recursive --require should" | ||
}, | ||
"pre-commit": [ | ||
"lint" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.