CPF/CNPJ
This package does some CPF/CNPJ magic. It allows you to create, validate and format CPF/CNPJ.
Installation
Using bower:
$ bower install cpf_cnpj --save
Using NPM:
$ npm install cpf_cnpj --save
Usage
// Node.js-specificvar CPF = CPF;var CNPJ = CNPJ; CPF;//=> true CPF;//=> 53282085796 CPF;//=> 532.820.857-96 CPF; // generate formatted number//=> 838.684.734-40 CPF; // generate unformatted number//=> 72777632898 //========================================================== CNPJ;//=> true CNPJ;//=> 41381074673865 CNPJ;//=> 41.381.074/6738-65 CNPJ; // generate formatted number//=> 54.385.406/3140-07 CNPJ; // generate unformatted number//=> 07033324230766
Strict Validation
By default, validations will strip any characters you provide. This means that the following is valid, because only numbers will be considered:
CNPJ;//=> true CNPJ;//=> 41381074673865
If you want to strict validate strings, use the following signature:
CPF;CNPJ;
The same example would now return false
:
CNPJ;//=> false
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am "Added some feature"
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request