Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2.validator.validators
Class EmailValidator

    java.lang.Object
      com.opensymphony.xwork2.validator.validators.ValidatorSupport
          com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
              com.opensymphony.xwork2.validator.validators.RegexFieldValidator
                  com.opensymphony.xwork2.validator.validators.EmailValidator

All Implemented Interfaces:
  FieldValidator, ShortCircuitableValidator, Validator

    public class EmailValidator

extends RegexFieldValidator

EmailValidator checks that a given String field, if not empty, is a valid email address. The regular expression used to validate that the string is an email address is:

     \\b^['_a-z0-9-\\+]+(\\.['_a-z0-9-\\+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)\*\.([a-z]{2,6})$\\b

You can also specify expression, caseSensitive and trim params as a OGNL expression, see the example below.

- fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required

Check also documentation of the RegexpValidator for more details - the EmailValidator bases on it. Do not use ${regexExpression}, ${caseSensitiveExpression} and ${trimExpression} as an expression as this will turn into infinitive loop!

         <!-- Plain Validator Syntax -->
         <validators>
             <validator type="email">
                 <param name="fieldName">myEmail</param>
                 <message>Must provide a valid email</message>
             </validator>
         </validators>

         <!-- Field Validator Syntax -->
         <field name="myEmail">
            <field-validator type="email">
               <message>Must provide a valid email</message>
            </field-validator>
         </field>

         <!-- Field Validator Syntax with expressions -->
         <!-- Only available when used with xml based configuration, if you want to have the same
                 flexibility with annotations use @RegexFieldValidator instead -->
         <field name="myEmail">
            <field-validator type="email">
               <param name="regexExpression">${emailPattern}</param> <!-- will be evaluated as: String getEmailPattern() -->
               <param name="caseSensitiveExpression">${emailCaseSensitive}</param> <!-- will be evaluated as: boolean getEmailCaseSensitive() -->
               <param name="trimExpression">${trimEmail}</param> <!-- will be evaluated as: boolean getTrimEmail() -->
               <message>Must provide a valid email</message>
            </field-validator>
         </field>

Version:
  $Date$ $Id$
Author:
  jhouse, tm_jee

Field Summary
`static String` | `EMAIL_ADDRESS_PATTERN`

Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
`defaultMessage, log, messageKey, stack`

Constructor Summary
`EmailValidator()`

Method Summary

Methods inherited from class com.opensymphony.xwork2.validator.validators.RegexFieldValidator
`getRegex, isCaseSensitive, isTrimed, setCaseSensitive, setCaseSensitiveExpression, setRegex, setRegexExpression, setTrim, setTrimExpression, validate`

Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
`getFieldName, getValidatorType, setFieldName, setValidatorType`

Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
`addActionError, addFieldError, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setValidatorContext, setValueStack`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.opensymphony.xwork2.validator.Validator
`getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack`

Field Detail

### EMAIL_ADDRESS_PATTERN

    public static final String EMAIL_ADDRESS_PATTERN

See Also:
  Constant Field Values

Constructor Detail

### EmailValidator

    public EmailValidator()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000–2018 Apache Software Foundation. All rights reserved.