Home

Awesome

cpf

Functions to handle Brazilian CPF numbers

Status


Precisando de um desenvolvedor? Entre em contato: theuves@gmail.com


Installation

You can install it with npm or yarn.

Try:

Usage

const CPF = require('cpf');

Now, CPF is a object with some functions:

CPF.format(cpf)

Format a CPF number.

Example

CPF.format('11144477735');
//=> '111.444.777-35'

Parameters

Returns a string with the formatted CPF number.

CPF.generate(formatted, invalid)

Generate a random CPF number.

Parameters

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);
// false

Parameters

Returns the check result.

License

MIT © Matheus Alves