validation-br: biblioteca TypeScript para validar CPF, CNPJ e outros documentos brasileiros
The validation-br library, written in TypeScript, checks 21 Brazilian document types, including CPF, CNPJ (alphanumeric included), CNH, CEP, voter registration, boleto and Pix. It has no runtime dependencies and supports both ESM and CommonJS modules. Because documents are usually validated inside schemas from libraries like Zod or Yup, the project provides 16 integration guides with runnable examples. Its validator functions return true or false rather than throwing exceptions, and since version 2.10 they check the exact input format, so extra spaces or unusual separators are rejected. The article shows how to combine these functions with Zod and Yup schemas to validate and normalize fields such as CPF, CNPJ and CEP.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in