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 🙏

© 2026 – Pkg Stats / Ryan Hefner

br-docs

v1.1.14

Published

Utilitários para validação e formatação de documentos brasileiros como CPF, telefone, CEP e CNPJ.

Readme

🇧🇷 BR Docs · Validação e formatação de documentos brasileiros (TypeScript)

npm version npm downloads license

⭐ Destaque: suporte ao novo CNPJ alfanumérico

O BR Docs já está preparado para o cenário do CNPJ alfanumérico (novo padrão), mantendo a compatibilidade com o CNPJ numérico tradicional.

Se você quer evitar retrabalho quando esse padrão virar comum no seu produto, já pode integrar agora.


Uma biblioteca simples, modular e pronta para produção para validação, formatação e parsing de documentos brasileiros — com foco em DX (Developer Experience), consistência e testes.

✅ TypeScript + tipagem forte ✅ API pequena e previsível (isValid, format, parse) ✅ Sem dependências pesadas ✅ Ideal para APIs, front-ends, formularios, pipes/validators, middlewares e RPA


📦 Instalação

npm install br-docs
# ou
yarn add br-docs
# ou
pnpm add br-docs

✅ Importação

import { Cpf, Cnpj, Email, Phone, Cep, Pix, Uuid, Cnh } from "br-docs";

⚡ Exemplo rápido (uso típico em validação de formulário)

import { Cpf, Email } from "br-docs";

const cpf = "123.456.789-09";
const email = "[email protected]";

if (!Cpf.isValid(cpf)) throw new Error("CPF inválido");
if (!Email.isValid(email)) throw new Error("Email inválido");

🧩 Documentos suportados

  • CPF (validar / formatar / parse)
  • CNPJ (inclui cenário alfanumérico) (validar / formatar / parse)
  • Telefone/Celular (validar / formatar / parse)
  • CEP (validar / formatar / parse)
  • Email (validar)
  • PIX (validar: CPF, CNPJ, email, telefone)
  • UUID (validar)
  • CNH (validar)
  • BOLETO BANCÁRIO (validar / formatar / parse)

📘 Exemplos de uso

CNPJ (com suporte ao padrão alfanumérico)

import { Cnpj } from "br-docs";

Cnpj.isValid("11.222.333/0001-81"); // true/false
Cnpj.format("11222333000181"); // "11.222.333/0001-81"
Cnpj.parse("11.222.333/0001-81"); // "11222333000181"

---

## 🧱 Interface genérica (API consistente)

Todos os módulos seguem um contrato simples e previsível:

```ts
export interface IValidator<T> {
  isValid(input: T): boolean;
}

export interface IFormatter<T> {
  format(input: T): string;
}

export interface IParser<T> {
  parse(input: T): string;
}

export interface IDocumentHandler<T>
  extends IValidator<T>, IFormatter<T>, IParser<T> {}

Isso facilita plugar em:

  • pipes/validators (NestJS, Zod, Yup)
  • middlewares/DTO validation
  • componentes de input no front
  • regras de domínio (clean architecture)

📚 Documentação completa

Acesse a documentação: https://br-docs-1.gitbook.io/br-docs/


🤝 Contribuindo

  1. Faça um fork do projeto
  2. Crie uma branch (git checkout -b feature/nova-feature)
  3. Commit (git commit -m "feat: minha feature")
  4. Push (git push origin feature/nova-feature)
  5. Abra um Pull Request

Licença

ISC