All Projects â†’ fnando â†’ cnpj

fnando / cnpj

Licence: MIT license
🇧🇷 Validate, generate and format CNPJ numbers

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to cnpj

insomnia-plugin-documents-br
O plugin tem a finalidade de gerar documentos e alguns dados mais usados, o foco é para dados do Brasil.
Stars: ✭ 21 (-73.08%)
Mutual labels:  cnpj
Brasil
.NET DevPack BR é uma coleção de utilidades como classes de documentos nacionais (CPF, CNPJ) com validação e classes de utilidade em geral. Desenvolvido para ser utilizado junto com o NetDevPack
Stars: ✭ 64 (-17.95%)
Mutual labels:  cnpj
rede-cnpj
Visualização gráfica de relacionamentos entre sócios e empresas com dados públicos de CNPJ.
Stars: ✭ 40 (-48.72%)
Mutual labels:  cnpj
cnpj
🇧🇷 Format, validate and generate CNPJ numbers in Node & Deno
Stars: ✭ 26 (-66.67%)
Mutual labels:  cnpj
burocracia.cr
No dependency Crystal shard to validate, generate and format Brazilian burocracias such as CPF, CNPJ and CEP
Stars: ✭ 21 (-73.08%)
Mutual labels:  cnpj
flunt.br
Extensions of Flunt for Brazilian projects
Stars: ✭ 42 (-46.15%)
Mutual labels:  cnpj
cnpj-sqlite
Script em python para carregar os arquivos de cnpj com dados públicos da Receita Federal para o formato sqlite
Stars: ✭ 60 (-23.08%)
Mutual labels:  cnpj

CNPJ

Build Status NPM package version License: MIT Minified size Minified+Gzip size

This package does some CNPJ magic. It allows you to create, validate and format CNPJ documents.

HINT: Check out the CPF counter part available at https://github.com/fnando/cpf.

Installation

This lib is available as a NPM package. To install it, use the following command:

npm install @fnando/cnpj --save

If you're using Yarn (and you should):

yarn add @fnando/cnpj

Usage

// Node.js-specific
const cnpj = require("@fnando/cnpj/commonjs");

// @import
import * as cnpj from "@fnando/cnpj"; // import the whole library
import { isValid as isValidCnpj } from "@fnando/cnpj"; // import just one function

// import via <script>; the lib will available as window.CNPJ
// <script src="cnpj.js"></script>

cnpj.isValid("41.381.074/6738-65");
//=> true

cnpj.isValid("41381074673865");
//=> true

cnpj.strip("41.381.074/6738-65");
//=> 41381074673865

cnpj.format("41381074673865");
//=> 41.381.074/6738-65

cnpj.generate(true); // generate formatted number
//=> 54.385.406/3140-07

cnpj.generate(); // generate unformatted number
//=> 07033324230766

On the web, without transformation, just use web/cnpj.min.js.

Strict Validation

By default, validations will strip any characters you provide. This means that the following is valid, because only numbers will be considered:

cnpj.isValid("41#381#074-----6738\n\n65");
//=> true

cnpj.strip("41#381#074-----6738\n\n65");
//=> 41381074673865

If you want to strict validate strings, use the following signature:

cnpj.isValid(number, strict);

The same example would now return false:

cnpj.isValid("41#381#074-----6738\n\n65", true);
//=> false
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].