Reputation: 13634
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?
Upvotes: 0
Views: 3583
Reputation: 5295
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
Upvotes: 1