cakephp/localized

15-digit Brazilian CNPJ

lh-import opened this issue · 7 comments

Created by César de Tassis Filho, 21st Mar 2013. (originally Lighthouse ticket #18):


New Brazilian CNPJs are 15 digits instead of 14 (that is already implemented) and I don't know at what point the 14-digit validation is compatible.
The validation needs to be updated to support those new CNPJs.
There are already some implementations saying they support 15-digit CNPJ (like this one for jQuery: http://blog.shiguenori.com/2009/05/29/validar-cpf-cnpj-com-jquery-validate/), but I did not found any official website telling how it should be validated.

18th Jul 2013, Marc Würth said:


Cesar, have you found anything about this issue?
If so it would be great if you could contribute some code to the GitHub repo at https://github.com/cakephp/localized

Short general info for interested people:
http://en.wikipedia.org/wiki/CNPJ

19th Jul 2013, César de Tassis Filho said:


I developed a validation function for 15-digit brazilian CNPJ.
It is backward compatible with 14-digit CNPJ validation because the algorithm presupposes expansion.
I forgot this ticket but I will contribute to CakePHP Localized project.
Thanks for replying :)

Is anyone able to provide a PR with the suggested changes?
Otherwise we might have to close this until someone comes up with one.

@CTassisF we still have this old issue open... Do you think you could provide your validation function for 15-digit brazilian ? Or should we close this ?

annuh commented

I can't find any examples of a 15-digit CNPJ. Does somebody have these?

Made some changed to the CNPJ validation function: #162., based on the Respect/Validation package. But I'm not sure if this solves anything.

There is no CNPJ of 15 digits. Only 14 Digits.
What may be happening is that some places are placed 0 on the left. But it must be ignored.
Example: 012.456.678/0001-90
Correct: 12.456.678/0001-90

Then please amend with some examples, and strip out any leading 0 if you want to for validation.