respect-validation/docs/validators/Cnpj.md
Valdeir S 570ba481b1 Add Support for Alphanumeric CNPJ
Due to the continuous increase in the number of companies and the
imminent exhaustion of available CNPJs (Brazilian taxpayer
identification numbers), the Brazilian Federal Revenue Service is
instituting the alphanumeric CNPJ. The initiative aims to
facilitate the identification of all companies and improve the
business environment, contributing to the economic and social
development of Brazil.

The alphanumeric CNPJ will be assigned, starting in July 2026,
exclusively to new registrations.

Changes:

- Add support for alphanumeric CNPJ validation
- Format code according to PHPCS standards
- Simplify CNPJ conversion to uppercase character array
- Add documentation about CNPJ structure
2026-02-04 13:20:30 +01:00

1.6 KiB

Cnpj

  • Cnpj()

Validates the structure and mathematical integrity of Brazilian CNPJ identifiers. Ignores non-digit chars, so use ->digit() if needed.

v::cnpj()->assert('00394460005887');
// Validation passes successfully

v::cnpj()->assert('12ABC34501DE35');
// Validation passes successfully

Templates

Cnpj::TEMPLATE_STANDARD

Mode Template
default {{subject}} must be a CNPJ
inverted {{subject}} must not be a CNPJ

Template placeholders

Placeholder Description
subject The validated input or the custom validator name (if specified).

Categorization

  • Identifications

Changelog

Version Description
3.0.0 Templates changed
0.3.9 Created

See Also