hibernate validiate list of integer
I have a list of integer like this:
private List<Integer> indexes;
Is there a way to valid individual mem开发者_如何学Cber to be in a range of 0-9? I see @Range and @Valid but can't find a way to make it work with List.
Thanks for your help,
Only @Size and @Valid can be used on Collections, however you can use some wrapper object instead of "Integer" to validate your ints, e.g.:
public class Index {
@Range( min = 0, max = 9 )
private Integer value;
}
public class Container {
@Valid
private List<Index> indexes;
}
This should do the trick
精彩评论