I have the following class:
Code:
public class Foo {
...
@AssertTrue(message="Foo is not valid")
public boolean isValid() {
// perform some validation logic and return either true or false
}
....
}
When I create an instance of Foo and validate this instance, the method isValid is called twice. Why is this method called twice?
This is how I validate the instance
Code:
...
Foo foo = new Foo();
...
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<Foo>> violations = validator.validate(foo);