Testing JSR-303 Using the OR Relationship

I have a field in my bean that I would like to be either Null or a date in the past. JSR-303 provides annotations for Null and Past, but if I apply both, it will never be checked, because it cannot be both Null and Past. I would like to combine the checks against OR. I am sure that I will need to create my own implementation of the validator for myself, but I hope that I have something missing, and one of you can show me how easy it is to combine existing validators with respect to OR.

+3
source share
1 answer

All JSR-303 annotations enable Null through by default. (Except, obviously, NotNull!) Just using @Past is implicitly "past or null".

+6
source

Source: https://habr.com/ru/post/1775024/


All Articles