Java Reference
In-Depth Information
Validator/Type Converter
{2}
{3}
minlength= N
N
maxlength= N
N
minvalue= N
N
maxvalue= N
N
NumberTypeConverter 3
range minimum
range maximum
For example, the @Validate(minvalue=N) validation provides the value
for N . If the user enters 15 in an Age field for which you have @Vali-
date(minvalue=18) , we could use this:
{1} is below the minimum {0} of {2}
to produce the following error message:
15 is below the minimum age of 18
Let's change the error messages in the contact form. For example, if the
user enters a date in the future, such as 2040-01-27 , the error message
is currently as follows:
The value supplied (Fri Jan 27 00:00:00 EST 2040) for field Birth date is
invalid.
This message is quite long and doesn't say why the birth date is invalid.
The errorName for an expression= validation is valueFailedExpression . Using
the
key,
the
message
can
be
contact.birthDate.valueFailedExpression
changed to a less intimidating and more informative message:
Download email_15/res/StripesResources.properties
contact.birthDate.valueFailedExpression=The birth date is in the future.
Using the field names and error names, we can customize the text for
the other error messages as well:
Download email_15/res/StripesResources.properties
contact.firstName.valueTooLong=The first name cannot exceed {2} characters.
contact.lastName.valueTooShort=The last name must be at least {2} characters.
contact.lastName.valueTooLong=The last name cannot exceed {2} characters.
contact.email.valueNotPresent=The email address is required.
contact.birthDate.invalidDate=The birth date is not valid.
Provided when an outOfRange error occurs.
3.
 
 
Search WWH ::




Custom Search