Subject: | No error reported if the CNPJ is not only a number |
I was trying to validate several CPNJ's and got one registry that had
the value "FARMACIA FECHOU" instead of number or anything else that
could at least look like an CPNJ. The problem is that the function
test_cnpj returned an OK status, although I got the warnings from perl
below:
Argument "A" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "R" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "M" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "A" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "C" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "I" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "A" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "F" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "E" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "C" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "H" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "O" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "F" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "A" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "R" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "M" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "A" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "C" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "I" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "A" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "F" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "E" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "C" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "H" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "O" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
Argument "U" isn't numeric in multiplication (*) at
C:/strawberry/perl/site/lib/Business/BR/Ids/Common.pm line 25.
I solved this by using a simple regular expression that look for letters
in the data passed as a CNPJ number, but I think this is more a hack
then a robust solution. Probably the test should be remove all "/" and
"-" and only then validate if the data is composed only by numbers.
Besides that, the module works great! Thank you!