Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cpf

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpf

Functions to handle brazilian CPF numbers.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.6K
decreased by-25.42%
Maintainers
1
Weekly downloads
 
Created
Source

cpf

Functions to handle brazilian CPF numbers

Status

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:

  • format
  • generate
  • isValid

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} true by default. It will generate a formatted CPF number.
  • invalid {boolean} false by 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);
// false
Parameters
  • cpf {string} Check if the CPF number is valid.
  • byLength {boolean} false by default. Check only if the length is valid.

Returns the check result.

License

MIT © Matheus Alves

FAQs

Package last updated on 04 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc