Bean Validation of dependent fields

Asked

Viewed 119 times

1

I’m starting with bean validation and I need to validate dependent fields.

Example : I have the fields dataInicio and dataFim The field dataFim cannot be smaller than the starting date.

I know I can create my own annotation, but I don’t know how or if it is possible to use the dataInitious field in the dataFim validator.


I was able to create the validator by the example of question/9284450

  • 1

    Last time I checked the API, you couldn’t do this natively. But you could create a validator for the class as a whole and then compare the fields. The downside is that it is difficult to reuse the code and at the time had to make use of specific implementation methods that I was using.

  • You have some documentation on how to create the class validator ?

  • I got an example on the link http://answall.com/questions/121847/bean-validation-country-dependent

No answers

Browser other questions tagged

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