net.sourceforge.stripes.validation
Annotation Type Validate


@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD})
@Documented
public @interface Validate

Primary annotation used to specify validations for form fields. Allows quick and easy specification of the most common types of validation logic, as well as a way to specify custom validations.

Author:
Tim Fennell

Optional Element Summary
 Class<? extends TypeConverter> converter
          A type converter to use to convert this field from String to it's rich object type.
 boolean encrypted
          If true, then a parameter value to be bound to this field must be an encrypted string.
 String expression
          Specifies an expression in the JSP expression language that should be evaluated to check the validity of this field.
 String field
          The name of the field to validate.
 boolean ignore
          If set to true will cause the property to be ignore by binding and validation even if it was somehow submitted in the request.
 String label
          The natural language name to use for the field when reporting validation errors, generating form input labels, etc.
 String mask
          Specifies a regular expression mask to be used to check the format of the String value submitted.
 int maxlength
          Specifies a maximum length of characters that must be submitted.
 double maxvalue
          Specifies the maximum numeric value acceptable for a numeric field.
 int minlength
          Specifies a minimum length of characters that must be submitted.
 double minvalue
          Specifies the minimum numeric value acceptable for a numeric field.
 String[] on
          If required=true, restricts the set of events to which the required check is applied.
 boolean required
          If set to true, requires that a non-null, non-empty value must be submitted for the field.
 boolean trim
          Trim white space from the beginning and end of request parameter values before attempting validation, type conversion or binding.
 

field

public abstract String field
The name of the field to validate. This attribute is ignored when the validation is attached to a simple (one form field to one ActionBean field) property, and is used only when specifying nested validations.

Default:
""

encrypted

public abstract boolean encrypted
If true, then a parameter value to be bound to this field must be an encrypted string. It also implies that when the value of this field is rendered by certain tags (e.g., InputHiddenTag) that it is to be rendered as an encrypted string. This prevents clients from injecting random values.

Default:
false

required

public abstract boolean required
If set to true, requires that a non-null, non-empty value must be submitted for the field.

Default:
false

trim

public abstract boolean trim
Trim white space from the beginning and end of request parameter values before attempting validation, type conversion or binding.

See Also:
String.trim()
Default:
true

on

public abstract String[] on

If required=true, restricts the set of events to which the required check is applied. If required=false (or omitted) this setting has no effect. This setting is entirely optional and if omitted then the field will simply be required for all events.

Can be specified as either a positive list (e.g. on={"save, "update"}) in which case the required check will be performed only on the listed events. Can also be specified as an inverted list (e.g. on="!new") in which case the check will be performed on all events that are not listed. Cannot contain a mix of "!event" and "event" since it does not make sense!

Default:
{}

ignore

public abstract boolean ignore
If set to true will cause the property to be ignore by binding and validation even if it was somehow submitted in the request.

Since:
Stripes 1.1
Default:
false

minlength

public abstract int minlength
Specifies a minimum length of characters that must be submitted. This validation is performed on the String value before any other validations or conversions are made.

Default:
-1

maxlength

public abstract int maxlength
Specifies a maximum length of characters that must be submitted. This validation is performed on the String value before any other validations or conversions are made.

Default:
-1

minvalue

public abstract double minvalue
Specifies the minimum numeric value acceptable for a numeric field. This validation is performed after the field has been converted to it's java type. This validation is only valid on numeric types (including BigInteger and BigDecimal).

Default:
4.9E-324

maxvalue

public abstract double maxvalue
Specifies the maximum numeric value acceptable for a numeric field. This validation is performed after the field has been converted to it's java type. This validation is only valid on numeric types (including BigInteger and BigDecimal).

Default:
1.7976931348623157E308

mask

public abstract String mask
Specifies a regular expression mask to be used to check the format of the String value submitted. The mask will be compiled into a java.util.regex.Pattern for use.

Default:
""

expression

public abstract String expression

Specifies an expression in the JSP expression language that should be evaluated to check the validity of this field. In the case of lists, arrays and maps the expression is evaluated once for each value supplied. The expression is evaluated only if a value is supplied - it will not be evaluated if the user did not supply a value for the field.

The value being validated is available in the EL variable 'this'. Properties of the ActionBean (including the context) can be referenced directly, as can values in request and session scope if necessary.

Note: it is not necessary to encapsulate the expression in ${} as on a JSP page.

Default:
""

converter

public abstract Class<? extends TypeConverter> converter
A type converter to use to convert this field from String to it's rich object type. If none is specified (which should be very common) then the default converter for the target type of object will be used.

Default:
net.sourceforge.stripes.validation.TypeConverter.class

label

public abstract String label
The natural language name to use for the field when reporting validation errors, generating form input labels, etc. This will only be used if a localized field name cannot be found in the resource bundle.

See Also:
LocalizationUtility.getLocalizedFieldName(String, String, Class, java.util.Locale)
Default:
""


? Copyright 2005-2006, Stripes Development Team.