开发者

JSR-303 validation using an OR relationship

开发者 https://www.devze.com 2023-01-25 19:31 出处:网络
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 the it will never validate because it can\'t be

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 the it will never validate because it can't be both Null and Past. I would like to combine the validations in an OR relationship. I'm pretty sure I'll have to create my own v开发者_如何学JAVAalidator implementation for that, but I'm hoping I'm missing something and one of you can show me how to easily combine the existing validators in an OR relationship.


All of the default JSR-303 annotations allow Null through. (Except, obviously, NotNull!) Simply using @Past is implicitly "in the past, or null."

0

精彩评论

暂无评论...
验证码 换一张
取 消