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.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

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

cpf-check

Gerador, validador e formatador de CPF que roda tanto no navegador quanto no servidor. Super pequeno, apenas 447 Bytes gzipped.

Build Status Coverage Status npm version npm downloads per month

(README available in english in README-en).

Instalação

Instale a última versão do cpf-check:

npm install cpf-check --save

Agora é só usá-lo no seu index.html

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

Ou importa-lo como um módulo:

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

// ou, em ES6+

import CPF from 'cpf-check';

Esse módulo é compativel com o padrão UMD, portanto é compatível com o RequireJs, AMD, CommonJs 1 e 2, etc.

API & Uso.

CPF.validate();

Assinatura do método:

validate(algumCpf: any): boolean;
import CPF, { validate } from 'cpf-check';

const algumCpf = '676.754.677-10';

CPF.validate(algumCpf);
// « true

validate(algumCpf);
// « true

validate('não-cpf');
// « false

validate('12345678910');
// « false
CPF.generate();

Assinatura do método:

generate(formatar?: boolean): string;

Esse método gera CPFs válidos.

import CPF, { generate } from 'cpf-check';

CPF.generate();
// « '67675467710'

generate(true);
// « '676.754.677-10'

generate();
// « '67675467710'
CPF.format();

Assinatura do método:

format(algumCpf: any): string;

Esse método adiciona pontuação a strings de CPFs.

import CPF, { format } from 'cpf-check';

const meuCpf = '67675467710';

CPF.format(meuCpf);
// « '676.754.677-10'

format(meuCpf);
// « '676.754.677-10'

format('não-cpf');
// « ''
CPF.strip();

Assinatura do método:

strip(algumCpf: any): string;

Esse método retira caracteres não numéricos de uma string.

import CPF, { strip } from 'cpf-check';

const algumCpf = '676.754.677-10';

CPF.strip(algumCpf);
// « '67675467710'

strip(algumCpf);
// « '67675467710'

Copyright (c) 2019 Marcel de Oliveira Coelho sob a Licença MIT. Go Crazy. :rocket:

Keywords

FAQs

Package last updated on 09 Jun 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