easy-cpf
v1.2.0
Published
A simple library to generate and validate cpf (Cadastro de pessoa física).
Downloads
46
Readme
Easy CPF
Easy cpf
is a lightweight library for validating and generating CPF (Cadastro de Pessoas Físicas) numbers in TypeScript and JavaScript.
Installation
You can install easy-cpf
via npm or yarn:
npm install easy-cpf
# or
yarn add easy-cpf
Usage
Validator
const { cpf } = require("easy-cpf");
const cpf = "123.456.789-09";
// true or false
cpf.validate(cpf);
Generator
const { cpf } = require("easy-cpf");
const randomCPF = cpf.generate();
// 123.456.789-10
console.log("Random CPF:", randomCPF);
As number
const { cpf } = require("easy-cpf");
const randomCPF = cpf.generate("number");
//12345678910
console.log("Random CPF:", randomCPF);