I have put validation for the following field,
@Min(1)
@Max(500)
private int length;
however, the length isn't a required field but when I didn't give the "length" in the input, I got this error:
"Validation error, message = must be greater than or equal to 1, path = length"
Looking at the @min and @max documentation, it says "null element is considered valid". I know that. If @min @max is only for primitive type, then why the documentation mentions "null" element is considered valid? Can someone let me know how to fix the validation problem? Many thanks.
length
to benull
? – Bashawint
can't ever benull
, it's a primitive type. If you want it to be nullable, you have to make it anInteger
. – Nga