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?
È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top