1
I’m trying to run the Hibernate CPF validation Constraint, but it just seems to reject valid CPF. The same test using Email Straint works normally:
EmailValidator validator = new EmailValidator();
validator.isValid("[email protected]", null);
But the number, no:
CPFValidator cpfValidator = new CPFValidator();
cpfValidator.isValid("755.611.810-09", null);
What’s the secret? I’m using version 5.3.6.Final of Hibernate Validator. I tried to remove the score, but the result is the same: CPF is not valid.
Tried to send only the numbers?
– EmanuelF
I tried yes! Looking at the source of the Cpfvalidator, it treats (or should treat) both cases: with and without score.
– Dherik
can put the Cpfvalidator source or the logic it uses to validate?
– EmanuelF
The code is a bit extensive as it takes advantage of methods from other classes. But the main class can be seen here: https://github.com/hibernate/hibernate-validator/blob/master/engine/src/java/org/hibernate/validator/internal/constraintvalidators/hv/br/CPFValidator.java. I tried to understand the problem with debug in the class, but I gave up..
– Dherik
vi that was put a treatment to accept in this format xxxxxx-xx tried to make a test in this way?
– EmanuelF
Why do you downvote?
– Dherik
I don’t know, but it wasn’t me. If you found the answer, add it.
– EmanuelF
@Emanuelf, unfortunately I didn’t find..
– Dherik