To answer my own question, as this is probably usefull as knowledge base: hibernate validations do ONLY work on get()
methods. So modifying above to getTestDefault()
works.
How to properly apply constraint group validations?
-
08-06-2023 - |
Domanda
I want to write a class validation. But the following does not result in an error. Why?
class TestVO {
@AssertTrue
public boolean testDefault() {
return false;
}
}
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
errors = validator.validate(new TestVO());
assertTrue(!errors.isEmpty()); //this fails. there are no errors! Why?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow