CPF Hibernate Constraint does not accept valid CPF?

Asked

Viewed 320 times

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.

  • 1

    Tried to send only the numbers?

  • 1

    I tried yes! Looking at the source of the Cpfvalidator, it treats (or should treat) both cases: with and without score.

  • 1

    can put the Cpfvalidator source or the logic it uses to validate?

  • 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..

  • vi that was put a treatment to accept in this format xxxxxx-xx tried to make a test in this way?

  • Why do you downvote?

  • I don’t know, but it wasn’t me. If you found the answer, add it.

  • @Emanuelf, unfortunately I didn’t find..

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.