Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

## com.opensymphony.xwork2.validator.annotations
Annotation Type Validations

    @Target(value={METHOD,TYPE})
    @Retention(value=RUNTIME)
    public @interface Validations

If you want to use several annotations of the same type, these annotation must be nested within the @Validations() annotation.

Annotation usage:

Used at METHOD level.

Annotation parameters:

Parameter | Required | Notes
--- | --- | ---
requiredFields | no | Add list of RequiredFieldValidators
customValidators | no | Add list of CustomValidators
conversionErrorFields | no | Add list of ConversionErrorFieldValidators
dateRangeFields | no | Add list of DateRangeFieldValidators
emails | no | Add list of EmailValidators
fieldExpressions | no | Add list of FieldExpressionValidators
intRangeFields | no | Add list of IntRangeFieldValidators
requiredFields | no | Add list of RequiredFieldValidators
requiredStrings | no | Add list of RequiredStringValidators
stringLengthFields | no | Add list of StringLengthFieldValidators
urls | no | Add list of UrlValidators
visitorFields | no | Add list of VisitorFieldValidators
stringRegexs | no | Add list of StringRegexValidator
regexFields | no | Add list of RegexFieldValidator
expressions | no | Add list of ExpressionValidator

Example code:

     @Validations(
               requiredFields =
                       {@RequiredFieldValidator(type = ValidatorType.SIMPLE, fieldName = "customfield", message = "You must enter a value for field.")},
               requiredStrings =
                       {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "stringisrequired", message = "You must enter a value for string.")},
               emails =
                       { @EmailValidator(type = ValidatorType.SIMPLE, fieldName = "emailaddress", message = "You must enter a value for email.")},
               urls =
                       { @UrlValidator(type = ValidatorType.SIMPLE, fieldName = "hreflocation", message = "You must enter a value for email.")},
               stringLengthFields =
                       {@StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, minLength="10" , maxLength = "12", fieldName = "needstringlength", message = "You must enter a stringlength.")},
               intRangeFields =
                       { @IntRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "intfield", min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")},
               dateRangeFields =
                       {@DateRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "datefield", min = "-1", max = "99", message = "bar must be between ${min} and ${max}, current value is ${bar}.")},
               expressions = {
                   @ExpressionValidator(expression = "foo > 1", message = "Foo must be greater than Bar 1. Foo = ${foo}, Bar = ${bar}."),
                   @ExpressionValidator(expression = "foo > 2", message = "Foo must be greater than Bar 2. Foo = ${foo}, Bar = ${bar}."),
                   @ExpressionValidator(expression = "foo > 3", message = "Foo must be greater than Bar 3. Foo = ${foo}, Bar = ${bar}."),
                   @ExpressionValidator(expression = "foo > 4", message = "Foo must be greater than Bar 4. Foo = ${foo}, Bar = ${bar}."),
                   @ExpressionValidator(expression = "foo > 5", message = "Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.")
       }
       )
       public String execute() throws Exception {
           return SUCCESS;
       }

Version:
  $Id: Validations.java 1216 2006-11-17 19:46:06Z jmitchell $
Author:
  jepjep, Rainer Hermanns

Optional Element Summary
`ConversionErrorFieldValidator[]` | `conversionErrorFields`
`CustomValidator[]` | `customValidators` Custom Validation rules.
`DateRangeFieldValidator[]` | `dateRangeFields`
`EmailValidator[]` | `emails`
`ExpressionValidator[]` | `expressions`
`FieldExpressionValidator[]` | `fieldExpressions`
`IntRangeFieldValidator[]` | `intRangeFields`
`RegexFieldValidator[]` | `regexFields`
`RequiredFieldValidator[]` | `requiredFields`
`RequiredStringValidator[]` | `requiredStrings`
`StringLengthFieldValidator[]` | `stringLengthFields`
`StringRegexValidator[]` | `stringRegexs`
`UrlValidator[]` | `urls`
`VisitorFieldValidator[]` | `visitorFields`

### customValidators

    public abstract CustomValidator[] customValidators

  Custom Validation rules.

  Default:
    {}

### conversionErrorFields

    public abstract ConversionErrorFieldValidator[] conversionErrorFields

  Default:
    {}

### dateRangeFields

    public abstract DateRangeFieldValidator[] dateRangeFields

  Default:
    {}

### emails

    public abstract EmailValidator[] emails

  Default:
    {}

### fieldExpressions

    public abstract FieldExpressionValidator[] fieldExpressions

  Default:
    {}

### intRangeFields

    public abstract IntRangeFieldValidator[] intRangeFields

  Default:
    {}

### requiredFields

    public abstract RequiredFieldValidator[] requiredFields

  Default:
    {}

### requiredStrings

    public abstract RequiredStringValidator[] requiredStrings

  Default:
    {}

### stringLengthFields

    public abstract StringLengthFieldValidator[] stringLengthFields

  Default:
    {}

### urls

    public abstract UrlValidator[] urls

  Default:
    {}

### visitorFields

    public abstract VisitorFieldValidator[] visitorFields

  Default:
    {}

### stringRegexs

    public abstract StringRegexValidator[] stringRegexs

  Default:
    {}

### regexFields

    public abstract RegexFieldValidator[] regexFields

  Default:
    {}

### expressions

    public abstract ExpressionValidator[] expressions

  Default:
    {}

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.