this.setCustomMsgKey(customMsgKey);
}
@Override
public ValidationResult validate(ValidationMessages allMessages) {
StandardValidationMessages messages = allMessages.getStandardMessages();
String str;
if(text != null)
str = text.getText();
else str = suggest.getText();
if(!isRequired() && str.equals(""))
return null;
str = str.trim();
if(str.equals(""))
return new ValidationResult(getErrorMessage(allMessages, messages.notAnInteger()));
if(!this.noMinMax) {
//Integer in range
try {
long value = Long.parseLong(str);
if(value < this.min || value > this.max) {
return new ValidationResult(getErrorMessage(allMessages, messages.notInRange(this.min, this.max, value), this.min, this.max, value));
}
}catch(NumberFormatException ex) {
return new ValidationResult(getErrorMessage(allMessages, messages.notAnInteger()));
}
}else {
//Any integer
try {
long value = Long.parseLong(str);
if(value < Integer.MIN_VALUE || value > Integer.MAX_VALUE)
return new ValidationResult(getErrorMessage(allMessages, messages.notAnInteger()));
}catch(NumberFormatException ex) {
return new ValidationResult(getErrorMessage(allMessages, messages.notAnInteger()));
}
}
return null;
}