Java Reference
In-Depth Information
Attribute
Type
Description
Name of nested field to validate.
field=
String
true
indicates a required field.
required=
boolean
on=
String
[]
Event handlers for which to apply
required=true
.
Minimum length of input.
minlength=
int
Maximum length of input.
maxlength=
int
EL expression to validate the input.
expression=
String
mask=
String
Regular expression that the input must match.
Minimum numerical value of input
minvalue=
double
Maximum numerical value of input.
maxvalue=
double
Type converter to use on the input.
converter=
Class
Trim input before validating;
true
by default.
trim=
boolean
Label to be displayed to the user.
label=
String
true
indicates not to bind the parameter.
ignore=
boolean
true
encrypts the parameter to prevent injected values.
encrypted=
boolean
Figure 4.2: The
@Validate
attributes
• Validation with an EL expression
• Matching a regular expression mask
• Minimum and maximum numerical value
Other validations are implemented as “pseudo” type converters. Pseudo
because the type conversion is from
String
to
String
, so the type is not
really converted. But when any type conversion occurs, the input is
validated. Stripes uses this trick to validate two
String
input formats:
• Email addresses
• Credit card numbers
use most of these attributes in the examples of this chapter. We'll see
Controlling Validation Execution
When a request arrives at an action bean, Stripes considers all valida-
tions you've added, no matter which event handler is the target. With
event handlers that require different validations, you'll want to control
Search WWH ::
Custom Search