سؤال

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 validator 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."

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top