You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Doug Bryant <db...@scra.org> on 2003/04/17 19:19:20 UTC

RE: [validator] validating that date is at least 5 business days from day

Attached is a stripped down version of a validator extension we are
using.  It validates that a date is in the future - but only in the
future.  It should be a fairly easy modification to make it validate 5
days in the future.

also...  put the below snippet of xml in one of your validator xml
config file in the "global" section (either the master or the custom one
for you app)

Hope this helps.

Doug

      <validator name="dateInFuture"
      		classname="DateValidator"
      		   method="validateDateInFuture"
      	 methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"
              depends="required, date"
                  msg="errors.dateInFuture">
      </validator>




On Thu, 2003-04-17 at 12:46, Wendy Smoak wrote:
> Matt:
> > Just wondering if the validator had this built in - I've already wrote
> a
> > custom validator in my validate(), but wanted to make sure I was
> > re-inventing the wheel.
> 
> Sounds like you're talking about doing it in the 'validate' method, and
> I'm
> talking about using the Validator plug-in and configuring a custom
> validator
> in the validation.xml file.
> 
> Either way, would you please share the Java code that does this
> validation?
> I'm sure it could be useful to someone searching the archives in the
> future,
> and I'm interested in eliminating the extra database calls that I'm not
> doing to get my own date validation to work.  I've never been successful
> convincing the Java Date/Calendar classes to do what I want them to, but
> maybe a good example will clear up my confusion.
> 
> Thanks,