com.opensymphony.xwork2.validator.validators
Class EmailValidator

java.lang.Object
  extended by com.opensymphony.xwork2.validator.validators.ValidatorSupport
      extended by com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
          extended by com.opensymphony.xwork2.validator.validators.RegexFieldValidator
              extended by 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-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-])+((\\.com)|(\\.net)|(\\.org)|(\\.info)|(\\.edu)|(\\.mil)|(\\.gov)|(\\.biz)|(\\.ws)|(\\.us)|(\\.tv)|(\\.cc)|(\\.aero)|(\\.arpa)|(\\.coop)|(\\.int)|(\\.jobs)|(\\.museum)|(\\.name)|(\\.pro)|(\\.travel)|(\\.nato)|(\\..{2,3})|(\\..{2,3}\\..{2,3}))$)\\b
 
 
     <!-- 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>
 
 

Version:
$Date: 2008-12-15 17:02:09 +0100 (Mo, 15 Dez 2008) $ $Id: EmailValidator.java 1885 2008-12-15 16:02:09Z musachy $
Author:
jhouse, tm_jee

Field Summary
static String emailAddressPattern
           
 
Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
defaultMessage, log, messageKey
 
Constructor Summary
EmailValidator()
           
 
Method Summary
 
Methods inherited from class com.opensymphony.xwork2.validator.validators.RegexFieldValidator
getExpression, isCaseSensitive, isTrimed, setCaseSensitive, setExpression, setTrim, 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, conditionalParse, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getParse, getValidatorContext, isShortCircuit, setDefaultMessage, setMessageKey, setMessageParameters, setParse, 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

emailAddressPattern

public static final String emailAddressPattern
See Also:
Constant Field Values
Constructor Detail

EmailValidator

public EmailValidator()


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