----- Original Message ----- From: "Joe Germuska" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Sunday, November 21, 2004 6:45 PM
Subject: Re: Want to reject all-whitespace text input.
At 1:33 PM -0500 11/21/04, Erik Weber wrote:I think what you want is to leave out the "required" validator, but to use the "minlength" validator with a value of 1. That should allow a blank, but not a String shorter than 1, and whitespace should be left out in the measurement. (I'm not positive as I don't have the source).
I think Erik's right. In any case, you won't get the mask validator to do it, since it only checks non-empty fields: ------- from o.a.s.validator.FieldChecks:
public static boolean validateMask(Object bean, ValidatorAction va, Field field, ActionMessages errors, HttpServletRequest request) {
String mask = field.getVarValue("mask");
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
try { if (!GenericValidator.isBlankOrNull(value) && !GenericValidator.matchRegexp(value, mask)) {
errors.add( field.getKey(), Resources.getActionMessage(request, va, field));
return false; } else { return true; } } catch (Exception e) { log.error(e.getMessage(), e); } return true; } -------
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]