The Validator was designed to work this way so there
could different groupings of validation rules. 
Because some times it may not make sense to continue
with certain validations until the form is in a
certain state.  The depends attribute in the pluggable
validator definitions is what controls these
groupings.  So to have validation performed on
everything at the same time, the depends attribute can
be either zero length or removed.

<validator name="mask"
    
classname="org.apache.struts.util.StrutsValidator"
        method="validateMask"
  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.invalid">


David

--- James Turner <[EMAIL PROTECTED]> wrote:
> Let's say I have two validations:
>     <field
>       property="gender"
>       depends="required">
>       <arg0 key="subscriberForm.gender.label"/>
>      </field>
>     <field
>       property="dateOfBirth"
>       depends="required,date">
>       <arg0 key="subscriberForm.dateOfBirth.label"/>
>      </field>
> 
> Now, on the form, I leave gender blank and put
> garbage in for dateOfBirth.
> 
> When the form validates, gender is given an error
> because it is blank, and 
> dateOfBirth is not flagged at all.
> 
> Why?
> 
> Because in
> org.apache.commons.validator.Validator.validate(), 
> hActionsRun 
> is defined outside of the main loop.  This
> means that if any field fails the "required" test,
> dateOfBirth will never 
> run the "date" check because the required
> dependency fails, even though it's for another
> field.
> 
> If you then put an entry in gender, required passes,
> and on the next form 
> submission, you finally get your error for
> dateOfBirth.
> 
> If hActionsRun were moved inside the loop, it would
> work 
> correctly.  However, it would mean that one field
> couldn't have a 
> dependency that was
> defined by another, which I think is OK, since
> that's not supposed to be 
> kosher as far as I can tell.  Should I submit that
> as a patch against commons?
> 
> James
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

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

Reply via email to