cnpj
cnpj copied to clipboard
feat: add support for alphanumeric CNPJ
Implements support for the new alphanumeric CNPJ format being introduced in July 2026 by Brazil's Federal Revenue Service, while maintaining full backward compatibility with numeric CNPJs.
Changes:
- Add alphanumeric validation with modulo 11 check digit algorithm
- Add strict mode option to validate() for uppercase enforcement
- Update format() to handle both numeric and alphanumeric CNPJs
- Update generate() with optional format parameter (numeric/alphanumeric)
- Add comprehensive test coverage (24 tests, all passing)
- Update documentation with examples and API details
The validate() function now accepts an optional second parameter: { strict: boolean } - rejects lowercase letters when true
The generate() function now accepts an optional parameter: { format: 'numeric' | 'alphanumeric' } - defaults to 'numeric'
All existing code continues to work without modifications.
Closes #33.