I have the following model class
public class ContactDetail {
@NotNull(message="StartNum cannot be null")
private int startNum;
@NotNull(message="EndNum cannot be null")
private int endNum; }
How would I go about validating the range size for these fields? I have tried adding
public int maxRangeSize=1000;
@AssertTrue(message="Range size is invalid" )
public boolean isRangeValid(){
Integer rangeSize= endNum-startNum;
if(rangeSize < 0 || rangeSize >= maxRangeSize)
{
return false;
}
return true;
}
but I would like to know if there is a way to show in the validation failure message which startnum and endnum or even whats the set maxrangesize, so the error will be useful to the user?