Skip to content

Comments

Adiciona checagem de CNPJ para saber se ele foi previamente formatado#65

Open
vmesel wants to merge 1 commit intoalvarofpp:mainfrom
vmesel:main
Open

Adiciona checagem de CNPJ para saber se ele foi previamente formatado#65
vmesel wants to merge 1 commit intoalvarofpp:mainfrom
vmesel:main

Conversation

@vmesel
Copy link

@vmesel vmesel commented Jul 24, 2024

Caso você envie um CNPJ já formatado para o CNPJ().mask(), ele retorna um CNPJ totalmente errôneo. Este PR visa resolver isso colocando uma checagem anterior a formatação.

Comment on lines +43 to +45
if not self._validate_input(doc, ['.', '/', '-']):
# Documento previamente formatado
return doc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O _validate_input irá retornar True em casos como '1-.22/.33./44.4-55', pois ele verifica apenas os caracteres. Creio que o ideal seria aplicar um RegEx para verificar se doc atende ao padrão de CNPJ, algo como [0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}.

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.

2 participants