struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David G. Friedman" <hum...@ix.netcom.com>
Subject RE: Problem with validation using both minlength and maxlength on the same field
Date Wed, 01 Dec 2004 18:28:28 GMT
Actually, they are both arg1 for their respective validators... See the
docs:
http://struts.apache.org/userGuide/dev_validator.html

minlength - validate input data isn't less than a specified minimum length.
Requires a minlength variable.

    <field property="name" depends="required,minlength">
        <arg0 key="customer.name"/>
        <arg1 name="minlength" key="${var:minlength}" resource="false"/>
        <var><var-name>minlength</var-name><var-value>3</var-value></var>
    </field>

maxlength - validate input data doesn't exceed a specified maximum length.
Requires a maxlength variable.

    <field property="name" depends="required,maxlength">
        <arg0 key="customer.name"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var><var-name>maxlength</var-name><var-value>30</var-value></var>
    </field>

Regards,
David

P.S. Question for the Day: Why do so many questions lately seem to be
clearly answered in the UserGuides yet always asked?

-----Original Message-----
From: Derek Broughton [mailto:derek@pointerstop.ca]
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, jesnook@fedex.com 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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


Mime
View raw message