Skip to content

feat: add alphanumeric cnpj support#60

Closed
fmartins-andre wants to merge 1 commit into
reactivando:mainfrom
fmartins-andre:feat-alphanumeric-cnpj-support
Closed

feat: add alphanumeric cnpj support#60
fmartins-andre wants to merge 1 commit into
reactivando:mainfrom
fmartins-andre:feat-alphanumeric-cnpj-support

Conversation

@fmartins-andre

Copy link
Copy Markdown
Contributor

No description provided.

@fmartins-andre fmartins-andre force-pushed the feat-alphanumeric-cnpj-support branch from 8920757 to 2020d5e Compare April 29, 2026 14:25
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 91.34% (-0.04%) from 91.377% — fmartins-andre:feat-alphanumeric-cnpj-support into reactivando:main

@fmartins-andre

Copy link
Copy Markdown
Contributor Author

Alteração na validação para dar suporte ao CNPJ alfanumérico.

Seguindo o exemplo de código fornecido pela própria Receita Federal, refatorei o código local para replicar o código de referência.
Foram adicionados novos testes para validar os CNPJ alfanuméricos.

Refs: https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/publicacoes/documentos-tecnicos/cnpj

AZagatti added a commit that referenced this pull request Jun 24, 2026
Adds alphanumeric CNPJ validation (12 alphanumeric + 2 numeric DV) per the Receita Federal spec, keeping legacy numeric support. Consolidates #59/#60/#62; base implementation from #62 (@JeanNesi). Full canonical test set; 115 tests pass.

Co-authored-by: Jean Carlos Nesi <jean.nesi@nextfit.com.br>
@AZagatti

Copy link
Copy Markdown
Collaborator

Muito obrigado pela contribuição, @fmartins-andre! 🙏

Revisei os três PRs de CNPJ alfanumérico comparando com a implementação oficial de referência da Receita Federal. A sua estava correta — usa o offset ASCII 48 ('0'→0, 'A'→17), exatamente como o spec define — e o seu conjunto de testes com os CNPJs canônicos da Receita (90.0xx.xxx…, 00000000000191, etc.) foi excelente; vários desses casos entraram na suíte final.

Acabei escolhendo a base do #62 por ficar um pouco mais enxuta e alinhada ao estilo do projeto (helper generateChecksum parecido com o validatePIS, sem throw, identificadores em inglês). Mas o seu PR foi decisivo para a cobertura de testes.

Como a main mudou bastante desde que você abriu este PR (pnpm 11, Biome/ultracite, atualização de dependências), consolidei tudo num PR novo sobre a main atual: #67. Vou fechar este em favor do #67. Valeu mesmo pelo trabalho!

@AZagatti

Copy link
Copy Markdown
Collaborator

Funcionalidade consolidada e mergeada no #67 (sua suíte de testes ajudou bastante). Obrigado!

@AZagatti AZagatti closed this Jun 24, 2026
AZagatti added a commit that referenced this pull request Jun 24, 2026
Adds alphanumeric CNPJ validation (12 alphanumeric + 2 numeric DV) per the
Receita Federal spec, keeping legacy numeric support. Consolidates
#59/#60/#62; base implementation from #62 (@JeanNesi). Full canonical test
set; 115 tests pass.

Co-authored-by: Jean Carlos Nesi <102368879+JeanNesi@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants