struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Evan Schnell <>
Subject Re: Role Based Struts Validation
Date Wed, 29 Jan 2003 16:49:14 GMT
PILGRIM, Peter, FM wrote:

>Actually I think that my understanding of the validator is flawed.
>By default the validator will not check a field unless you
>specify the "required". The way that "requiredif" is 
>implemented might be clue to what I need to do. 
The "required" and "requiredIf" rules have no special short-circuit 
behavior or impact on other rules.  It seems that all required fields 
must be specified before any other rules are executed, but I have never 
seen this behavior formally documented anywhere.  This behavior is (or 
has been) specific to Struts and does not occur when one uses the 
commons-validator from a non-struts application.   The point is that the 
specification of a field as  not required does not inhibit execution of 
other rules on that field.

The required rule really only has application when the field really is 
_required_.  It is still possible to validate the content of an optional 
field.  For example:

           <field property="email" depends="email">
               <arg0 key=""/>

This declaration guarantees that if the user enters a value for the 
email field it must be a valid email address.  If the user enters 
nothing, because the field is not required no error will be generated.  


Evan Schnell, Technical Lead
nVISIA, Twin Cities  "Digital Architecture and Construction"
7701 France Ave. S, Edina, MN 55435
Voice: 952.837.2577 -- Fax: 952.837.2578 -- Mobile: 612.232.5972

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message