for (String value : values) {
// Only run validations when there are non-empty values
if (value != null && value.length() > 0) {
if (validationInfo.minlength() != null
&& value.length() < validationInfo.minlength()) {
ValidationError error = new ScopedLocalizableError("validation.minlength",
"valueTooShort", validationInfo.minlength());
error.setFieldValue(value);
errors.add(error);
}
if (validationInfo.maxlength() != null
&& value.length() > validationInfo.maxlength()) {
ValidationError error = new ScopedLocalizableError("validation.maxlength",
"valueTooLong", validationInfo.maxlength());
error.setFieldValue(value);
errors.add(error);
}
if (validationInfo.mask() != null
&& !validationInfo.mask().matcher(value).matches()) {
ValidationError error = new ScopedLocalizableError("validation.mask",
"valueDoesNotMatch");
error.setFieldValue(value);
errors.add(error);
}
}
}
}