npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@b3coded/js-brasil

v2.4.0

Published

Javascript Utils para Brasil (cpf, cnpj...)

Downloads

52

Readme

js-brasil

Javascript Validate, Mask, Faker e Utils para Tipos do Brasil: Celular, CEP, Certidão, CNH, CNPJ, CNS, CPF, Currency, Date, ECT, EMAIL, Empresa, Endereço, Inscrição Estadual, Number, Percentage, Pessoa, PIS/PASEP, Placa de carro, Processo da justiça, RENAVAM , RG , Site, Telefone , Time (data/hora), Título de Eleitor , Veículo

Build Status

npm i js-brasil

ou

<script src="js-brasil.js"></script>

Módulos ValidateBR, MaskBR e FakerBR para nodejs ou browser.

Plugins para :

Veja tudo em ação no Gerador Brasileiro - http://geradorbrasileiro.com/

Ou veja um exemplo de código live: https://jsfiddle.net/mariohmol/qnmxhwrb/6/

Tipos Suportados

  • Cartão de Crédito - http://geradorbrasileiro.com/cartao.html (TODO #12)
  • Celular - http://geradorbrasileiro.com/celular.html
  • CEP - http://geradorbrasileiro.com/cep.html
  • Certidão - http://geradorbrasileiro.com/certidao.html
  • CID - http://geradorbrasileiro.com/cid.html (TODO #34)
  • CNAE - http://geradorbrasileiro.com/cnae.html (TODO #16)
  • CNH - http://geradorbrasileiro.com/cnh.html
  • CNPJ - http://geradorbrasileiro.com/cnpj.html
  • CNS - http://geradorbrasileiro.com/cns.html
  • Conta de Banco - http://geradorbrasileiro.com/contato.html (TODO #13)
  • CPF - http://geradorbrasileiro.com/cpf.html
  • CPF/CNPF - http://geradorbrasileiro.com/cpfcnpj.html (TODO #15)
  • Currency - http://geradorbrasileiro.com/others.html
  • Date - http://geradorbrasileiro.com/data.html
  • ECT - http://geradorbrasileiro.com/ect.html
  • EMAIL - http://geradorbrasileiro.com/email.html
  • Empresa - http://geradorbrasileiro.com/empresa.html
  • Endereço - http://geradorbrasileiro.com/endereco.html
  • Inscrição Estadual - http://geradorbrasileiro.com/inscricaoestadual.html - Todos os estados do Brasil
  • IPTU - http://geradorbrasileiro.com/iptu.html (TODO #26)
    • São Paulo e Curitiba OK
    • Outras capitais (TODO)
  • NIT - (TODO #14)
  • Number - http://geradorbrasileiro.com/others.html
  • Percentage - http://geradorbrasileiro.com/others.html
  • Pessoa - http://geradorbrasileiro.com/pessoa.html
  • PIS/PASEP - http://geradorbrasileiro.com/pis.html
  • Placa de carro - http://geradorbrasileiro.com/placa.html
  • Processo da justiça - http://geradorbrasileiro.com/processo.html
  • RENAVAM - http://geradorbrasileiro.com/renavam.html
  • RG - http://geradorbrasileiro.com/rg.html
    • SP/RJ - OK
    • Outros estado (TODO)
  • Site - http://geradorbrasileiro.com/site.html
  • SPED - http://geradorbrasileiro.com/sped.html (TODO: #24)
  • Telefone - http://geradorbrasileiro.com/telefone.html
  • Time (data/hora) - http://geradorbrasileiro.com/others.html
  • Título de Eleitor - http://geradorbrasileiro.com/titulo.html
  • Veículo - http://geradorbrasileiro.com/veiculo.html

ValidateBR

Verifique se os dados dos seus usuários são válidos

Node:

const { validateBr } = require('js-brasil');
const cpf = validateBr.cpf('123.456.789-00');

Typescript:

import { validateBr } from 'js-brasil';
const cpf = validateBr.cpf('123.456.789-00');

Browser:

<script src="js-brasil.js"></script>
<script>
var cpf = jsbrasil.validateBr.cpf('123.456.789-00');
</script>  

MaskBR

Formate seus dados com mascaras de tipos de dados brasileiros

Node:

const { maskBr } = require('js-brasil');
const cpf = maskBr.cpf('12345678900'); 
console.log(cpf) // '123.456.789-00'

Typescript:

import { maskBr } from 'js-brasil';
const cpf = maskBr.cpf('12345678900'); 
console.log(cpf) // '123.456.789-00'

Browser:

<script src="js-brasil.js"></script>
<script>
var cpf = jsbrasil.maskBr.cpf('12345678900'); 
console.log(cpf) // '123.456.789-00'
</script>  

FakerBR

Gerador de dados de teste usando tipos de dados brasileiro, similar o fakerjs

Node:

const { fakerBr } = require('js-brasil');
const cep = fakerBr.cep();

Typescript:

import { fakerBr } from 'js-brasil';
const cep = fakerBr.cep();

Browser:

<script src="js-brasil.js"></script>
<script>
var cep = jsbrasil.fakerBr.cep();
</script>  

UtilsBR

Métodos úteis para todos apps brasileiros, veja alguns exemplos

  const currency = utilsBr.currencyToNumber(' R$ 1.234.456,44 ');
  expect(currency).to.be.equal(1234456.44);
  const percent = utilsBr.currencyToNumber(' 1.234.456,44%');
  expect(percent).to.be.equal(1234456.44);
  const percent2 = utilsBr.currencyToNumber(' 12 % ');
  expect(percent2).to.be.equal(12);

Node:

const { utilsBr } = require('js-brasil');
const currency = utilsBr.currencyToNumber(' R$ 1.234.456,44 '); // 1234456.44
const percent2 = utilsBr.currencyToNumber(' 12 % '); // 12

Typescript:

import { utilsBr } from 'js-brasil';
const currency = utilsBr.currencyToNumber(' R$ 1.234.456,44 ');
const percent2 = utilsBr.currencyToNumber(' 12 % '); // 12

Browser:

<script src="js-brasil.js"></script>
<script>
var currency = jsbrasil.utilsBr.currencyToNumber(' 12 % '); // 12
</script>  

Angular

Utilize em angular 2 a 8 com:

  • ng-brazil - angular support for brazil apps - https://github.com/mariohmol/ng-brazil

React

Utilize com React:

  • react-brazil - react support for brazil apps - https://github.com/mariohmol/react-brazil

API

Quer usar estes métodos através de uma API Web? Entre em contato conosco!

Contribuir

Para ajudar veja nossa issues e use a seguinte documentação: Contribuir