validation-br 2.0 Released: TypeScript Library for Brazilian Document Validation
Developer klawdyo has released version 2.0 of validation-br, a TypeScript library for validating Brazilian documents such as CPF, CNPJ, CEP, Pix keys, CNH, and over a dozen other formats. The major change in this release is that each document type is now an immutable class modeled as a value object, meaning validation occurs at instantiation and throws an exception if the input is invalid, rather than returning a boolean. Shortcut functions like isCPF and isCNPJ are still available for developers who prefer a simple true/false check. The library ships with zero production dependencies, relying solely on native JavaScript and TypeScript APIs to keep the footprint small and reduce supply-chain security risks. It also supports the alphanumeric CNPJ format introduced by Brazil's Receita Federal in 2026, including the ability to generate valid fake values for testing purposes.
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