When i apply an annotation validator on a property, the validator will return true if the property is null.
Eg:
Code:
@ManyToMany
@Size(min=1) public List getUsers() { return users; }
When users = null, the validator will return true. I would expect it returns false because we don't know for sure that the size is at least 1.
I know that the documentation says that the @Size annotation should only be used on type array, list or map. One could argue that null is not an applicable type. But even then i would expect isValidate to return false because the value isn't applicable.
It appears this was already the intention of the author, because when i look at PatternValidator i see the following: (The value isn't applicable, thus isValid return false)
Code:
if ( !( value instanceof String ) ) return false;
Thus i wonder: Why do all the Validators return true when the value is null?