struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ram Venkataswamy" <r...@m7.com>
Subject RE: Problem with validation using both minlength and maxlength on the same field
Date Wed, 01 Dec 2004 18:12:01 GMT
This is do with argument number - change errors.maxlength={0} can not be
greater than {1} characters. 

To 

errors.maxlength={0} can not be greater than {2} characters.



-----Original Message-----
From: jesnook@fedex.com [mailto:jesnook@fedex.com] 
Sent: Wednesday, December 01, 2004 9:49 AM
To: user@struts.apache.org
Subject: Problem with validation using both minlength and maxlength on
the same field

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"  />
         </field>
...
...

SampleApp.properties
...
...
   errors.required={0} is required.
   errors.minlength={0} can not be less than {1} characters.
   errors.maxlength={0} can not be greater than {1} characters.
   errors.invalid={0} is invalid.

   errors.byte={0} must be a byte.
   errors.short={0} must be a short.
   errors.integer={0} must be an integer.
   errors.long={0} must be a long.
   errors.float={0} must be a float.
   errors.double={0} must be a double.

   errors.date={0} is not a date.
   errors.range={0} is not in the range {1} through {2}.
   errors.creditcard={0} is an invalid credit card number.
   errors.email={0} is an invalid e-mail address.
...
...
   sampleApp.myField.label=My field:
   sampleApp.myField.minLen=5
   sampleApp.myField.maxLen=5



If I enter 8 charcters in myField and submit I get "My field: can not be

less than 5 characters."

Any ideas what's wrong?

Thanks,

James

---------------------------------------------------------------------
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