That's strange, because the way I understand it is just the opposite.
What I understand is if a validation depends on another validation, then
this validation should not be triggered unless the first one succeeds.
Actually, this makes sense, because it's useless to try to validate an
empty field to make sure it's a date.

But anyway, if this is the case, what do you suggest?

In my validations.xml, I did not specify that this field depends on the
required validation. I don't think changing the validator declaration
would help, since the problem is with the code itself.

Thanks

-----Original Message-----
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 05, 2005 6:12 PM
To: Struts Users Mailing List
Subject: Re: Date validator does not ignore nulls

tarek.nabil wrote:

>      <validator name="date"
>            classname="org.apache.struts.util.StrutsValidator"
>               method="validateDate"
>         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"
>                  msg="errors.date"
>       jsFunctionName="DateValidations">
>
>Although the validator declares that it depends on required, so (as far

>as I understand) that means it should not be triggered if the value is 
>null or blank. Nevertheless, it is, and it shows the error that the 
>date is invalid. I checked the source for the class that performs the 
>validation, and obviously it adds the error to the errors collection if

>the value is null or blank. But I think it's not supposed to even get 
>called, because in the declaration of the validator, it says it depends

>on required.
>  
>
"Required" means the value must not be blank or null, right? So if a
validation depends on "required" that means that the value can't be
blank or null. So it _should_ be triggered on a blank or null.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to