Home > Guides > Core Developers Guide > Annotations > Validations Annotation

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

Usage

Used at METHOD level.

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
requiredStrings no Add list of RequiredStringValidators
stringLengthFields no Add list of StringLengthFieldValidators
urls no Add list of UrlValidators
visitorFields no Add list of VisitorFieldValidators
regexFields no Add list of RegexFieldValidator
expressions no Add list of ExpressionValidator

Examples

Different validations per method

Different validations per method is NOT supported for client-side validation!

To use different validations per method, the validateAnnotatedMethodOnly property must be set on the validation interceptor.

<interceptor-ref name="validation">
  <param name="validateAnnotatedMethodOnly">true</param>                
  <param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>

Here's a complete example of updating the default stack:

  <package name="default" extends="struts-default">
    <interceptors>
      <interceptor-stack name="content">
        <interceptor-ref name="exception"/>
                <interceptor-ref name="alias"/>
                <interceptor-ref name="servletConfig"/>
                <interceptor-ref name="prepare"/>
                <interceptor-ref name="i18n"/>
                <interceptor-ref name="chain"/>
                <interceptor-ref name="debugging"/>
                <interceptor-ref name="profiling"/>
                <interceptor-ref name="scopedModelDriven"/>
                <interceptor-ref name="modelDriven"/>
                <interceptor-ref name="fileUpload"/>
                <interceptor-ref name="checkbox"/>
                <interceptor-ref name="staticParams"/>
                <interceptor-ref name="params">
                  <param name="excludeParams">dojo\..*</param>
                </interceptor-ref>
                <interceptor-ref name="conversionError"/>
                <interceptor-ref name="validation">
  	            <param name="validateAnnotatedMethodOnly">true</param>                
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
      </interceptor-stack>
    </interceptors>
    <default-interceptor-ref name="default"/>
  </package>
</struts>