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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 01, 2004 9:49 AM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]