Question

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?
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top