It was for doing database validations. There would be no need to perform the database lookup if the regular expression or minLength fails. However, your reasons behind the way it was written make sense. I can't really see any reason why the more basic validations would _need_ to be performed first.
> -----Original Message----- > From: John McNally [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 17, 2003 10:23 AM > To: Turbine Developers List > Subject: Re: Proposed change to intake validation. > > > I think my reason was that any validations specific to a > subclass are likely to be more in line with the field than > the generic validations. > Since the first validation failure wins, giving the more > specific error message is preferred. Maybe I'm not > remembering a better reason for it, it does seem somewhat > arbitrary. What is the case for having the mask and length > checks prior to the subclass validations? > > john mcnally > > On Fri, 2003-01-17 at 07:34, Quinton McCombs wrote: > > Most of the validators extend DefaultValidator. The method > > doAssertValidity() is to be overridden in subclasses to preform > > additional validation. Here is the code for > assertValidity() from the > > DefaultValidator class: > > > > /** > > * Determine whether a testValue meets the criteria specified > > * in the constraints defined for this validator > > * > > * @param testValue a <code>String</code> to be tested > > * @exception ValidationException containing an error > message if the > > * testValue did not pass the validation tests. > > */ > > public void assertValidity(String testValue) > > throws ValidationException > > { > > message = null; > > > > if ((!required && minLength == 0) > > && (testValue == null || testValue.length() == 0)) > > { > > return; > > } > > else if (required > > && (testValue == null || testValue.length() == 0)) > > { > > message = requiredMessage; > > throw new ValidationException(requiredMessage); > > } > > > > // allow subclasses first chance at validation > > doAssertValidity(testValue); > > > > if (maskPattern != null) > > { > > boolean patternMatch = > > patternMatcher.matches(testValue, maskPattern); > > > > log.debug("Trying to match " + testValue > > + " to pattern " + maskString); > > > > if (!patternMatch) > > { > > message = maskMessage; > > throw new ValidationException(maskMessage); > > } > > } > > > > if (minLength > 0 && testValue.length() < minLength) > > { > > message = minLengthMessage; > > throw new ValidationException(minLengthMessage); > > } > > if (maxLength > 0 && testValue.length() > maxLength) > > { > > message = maxLengthMessage; > > throw new ValidationException(maxLengthMessage); > > } > > } > > > > > > Notice that doAssertValidity is called after testing the > required rule > > bute before any other others. Is there a reason for this? > It seems > > that it might be better for the basic forms of validation to occur > > before the subclass begins its validation. > > > > Thoughts? > > > > -- > > To unsubscribe, e-mail: > <mailto:turbine-dev-> [EMAIL PROTECTED]> > > For > additional commands, > e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > -- > To unsubscribe, e-mail: > <mailto:turbine-dev-> [EMAIL PROTECTED]> > For > additional commands, > e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
