I was trying to find it but I can't. I have my DTO where I am validating the data sent by user.
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
@Min(value = 0)
@Max( value = 6)
private byte[] days;
It is throwing an error:
No validator could be found for constraint 'javax.validation.constraints.Min' validating type 'short[]'. Check configuration for 'days'.
What is wrong with that?
You are using wrong contraints, Min and Max validates actual value, but you have an array. For validation of array length, use
@Size(min=0, max=6)
private byte[] days;
http://docs.oracle.com/javaee/6/api/javax/validation/constraints/Size.html
If you want to check if EVERY element of array has value between 0 - 6, you probably have to create your own validator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.