New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cpf-check

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpf-check

Validador de CPF Moderno, Isomórfico e Super Leve.

  • 1.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
311
decreased by-68.59%
Maintainers
1
Weekly downloads
 
Created
Source

cpf-check

CPF Validator, Generator e Formatter, runs both on browser and server-side. Incredibly Small 2.2KB (890bytes gziped!!). Build Status Coverage Status npm version

Instalation

Add the latest version of cpf-check to your package.json.

npm install cpf-check --save

Then you can use it in your index.html

<script type="text/javascript" src="./node_modules/cpf-check/dist/cpf.min.js"></script>
// window.CPF

Or, you can import it as a module:

const CPF = require('cpf-check');

// or, in ES6

import CPF from 'cpf-check';

Works on Node, any CommonJs Env. and as an AMD modules.

Usage & API

CPF(String): Boolean

The main export is a function that validates CPFs.

const CPF = require('cpf-check')
const myCpf = '676.754.677-10';

CPF(myCpf);
// true

CPF.validate(myCpf);
// true

The CPF.validate() is an alias for the CPF() method.

CPF.generate(): String

Generates valid CPFs:

CPF.generate();
// '676.754.677-10'

CPF.parse(String): String

Parse CPFs from text strings:

const myText = 'Hey, my CPF is 676.754.677-10';

CPF.parse(myText);
// '676.754.677-10'

CPF.format(String): String

Format (beautify) CPF strings:

const myCpf = '67675467710';

CPF.format(myCpf);
// '676.754.677-10'

CPF.strip(String): String

Strip (uglify) CPF strings:

const myCpf = '676.754.677-10';

CPF.strip(myCpf);
// '67675467710'

PRs

And if you find something that is not working as supposed to, please, open a PR.

Bonus!

If you're curious to know how this module works before implementing it, the source code is heavily commented! head to src/index.js to take a look!

Copyright (c) 2017 Marcel Coelho under the MIT license

Keywords

FAQs

Package last updated on 03 Aug 2017

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