You need to specify maxlength and minlength variables.

          <field
            property="myField"
            depends="minlength, maxlength, integer">
            <arg0 key="sampleApp.myField.label"/>
            <arg1 key="sampleApp.myField.minLen" name="minlength"  />
            <arg1 key="sampleApp.myField.maxLen" name="maxlength"  />
            <var>
                 <var-name>minlength</var-name><var-value>10</var-value>
            </var>
            <var>
                 <var-name>maxlength</var-name><var-value>20</var-value>
            </var>

Alternatively, if its an integer field you could use the intRange validator
instead

          <field
            property="myField"
            depends="integer,intRange">
            <arg0 key="sampleApp.myField.label"/>
            <arg1 key="${var:min}" resource="false"  />
            <arg2 key="${var:max}" resource="false"  />
            <var>
                 <var-name>min</var-name><var-value>10</var-value>
            </var>
            <var>
                 <var-name>max</var-name><var-value>20</var-value>
            </var>


Niall

----- Original Message ----- 
From: "David G. Friedman" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, December 02, 2004 12:46 AM
Subject: RE: Problem with validation using both minlength and maxlength on
the same field


> Derek,
>
> I'm seeing the same thing you described.  I'm sorry I didn't believe you.
> Sadly, I'm having a HELL of a time figuring out what's wrong because I
> recently upgraded my development setup to Struts 1.2.4 and Tomcat 5.5.4
and
> haven't used validation in a while.  Trying the 1.1.4 validator binary
> didn't help any.  I'm feeling really stupid since used to be able to get
> this to work.  Too many variables have changed on me. *sigh*
>
> Regards,
> David
>
> -----Original Message-----
> From: Derek Broughton [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 01, 2004 1:18 PM
> To: Struts Users Mailing List
> Subject: Re: Problem with validation using both minlength and maxlength
> on the same field
>
>
> On Wednesday 01 December 2004 13:49, [EMAIL PROTECTED] wrote:
> > I'm trying to validate a simple field.  I want to validate that the
field
> > is an integer, and meets the min and max length requirements.  In the
same
> > application I am able to correctly validate a date field so I'm
confident
> > my overall struts setup is correct.  However when I try to do both a min
> > and max length check on the same field, the max length check doesn't
work.
> >  If I exceed the max length I get the min length message.  Below is a
> > snippet from my validation.xml file.  I've setup my properties file to
> > include the min and max length constants.
> >
> > validation.xml
> > ...
> > ...
> >          <field
> >            property="myField"
> >            depends="minlength, maxlength, integer">
> >            <arg0 key="sampleApp.myField.label"/>
> >            <arg1 key="sampleApp.myField.minLen" name="minlength"  />
> >            <arg1 key="sampleApp.myField.maxLen" name="maxlength"  />
>
> Despite two other good looking answers, I'd have to say that it seems
> unlikely
> that these should _both_ be "arg1" :-)
> --
> derek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



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

Reply via email to