You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Quinn Stone <qs...@stoneconsultants.com> on 2006/05/05 22:33:42 UTC

Validwhen and whitespace

Struts 1.2.9, Validator 1.2.0.

If I used the "required" validation, when the user enters whitespace in a form
field, the validation fails. However, when using "validwhen" it seems that
whitespace is accepted. 

In the validation I'm using (below), if the user leaves lastName empty, an error
is generated. However, if the user enters whitespace, the validation passes. 

Is this expected behavior? I would expect "validwhen" to trim, but it doesn't
seem to.

Here's the validation. I'm trying to ensure that lastName is entered if any of
the other parent info is entered:

<!-- Validate second (optional) parent -->
<field property="parent[1].lastName" depends="validwhen,maxlength,mask">
    <arg key="labels.lastName"/>
    <arg key="labels.firstName"/>
    <arg key="Parent 2" resource="false"/>
    <msg name="validwhen" key="errors.secondParent"/>
    <var>
        <var-name>test</var-name>
        <var-value>(((((parent[1].firstName == null) and (parent[1].phoneData ==
"false")) and (parent[1].email == null)) and (parent[1].preferredName == null))
or (*this* != null))</var-value>
    </var>
    <arg name="maxlength" key="${var:maxlength}" resource="false"/>
    <var><var-name>maxlength</var-name><var-value>${nameLen}</var-value></var>
    <msg name="mask" key="errors.nameMask"/>
    <var>
        <var-name>mask</var-name>
        <var-value>${nameMask}</var-value>
    </var>
</field>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org