Package Exports
- cpf
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cpf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cpf
Functions to handle brazilian CPF numbers
Installation
You can install it with npm or yarn.
Try:
- npm:
npm install cpf - yarn:
yarn add cpf
Usage
const CPF = require('cpf');Now, CPF is a object with some functions:
formatgenerateisValid
CPF.format(cpf)
Format a CPF number.
Example
CPF.format('11144477735');
//=> '111.444.777-35'Parameters
cpf{string} A CPF number.
Returns a string with the formatted CPF number.
CPF.generate(formatted, invalid)
Generate a random CPF number.
Parameters
formatted{boolean}trueby default. It will generate a formatted CPF number.invalid{boolean}falseby default. It will generate a invalid CPF number.
Returns a CPF number.
CPF.isValid(cpf, byLength)
Check if a CPF number is valid.
Example
CPF.isValid('111.444.777-35');
// true
CPF.isValid('111.444.777-42');
// false
CPF.isValid('111.444.777-42', true);
// true
CPF.isValid('111.444.777', true);
// falseParameters
cpf{string} Check if the CPF number is valid.byLength{boolean}falseby default. Check only if the length is valid.
Returns the check result.
License
MIT © Matheus Alves