Tim wrote:
> Is there a way to validate a date against today's date?
> I can validate that a date is entered in a desired format but I'm not sure
how to
> validate that it is = to or > then today's date using just the
validation.xml.
> Do I have to use a custom validator?

I think you would have to do a custom validator.  I did, too, for a
different issue, and it wasn't terribly hard.  You need a class of your own
(ValidationUtil?) with a method: 
public static boolean lenientDate( Object bean, ValidatorAction va, Field
field, ActionErrors errors, Validator validator, HttpServletRequest request
)

Then an addition to validation.xml:
<form-validation>
  <global>
        <validator name="lenientDate"
                 classname="edu.asu.vpia.struts.ValidationUtil"
                 method="validateDate"
                 methodParams="java.lang.Object,
                               org.apache.commons.validator.ValidatorAction,
                               org.apache.commons.validator.Field,
                               org.apache.struts.action.ActionErrors,
                               org.apache.commons.validator.Validator,
                               javax.servlet.http.HttpServletRequest"
                 msg="errors.date">
      </validator>
   </global>
<formset> ...

Then use it in the 'depends' attribute as usual!  You might need some extra
pieces in ApplicationResources.properties depending on what errors you want
to show.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Reply via email to