Class EmailValidator
java.lang.Object
org.apache.commons.validator.routines.EmailValidator
- All Implemented Interfaces:
Serializable
Perform email validations.
Based on a script by Sandeep V. Tamhankar http://javascript.internet.com
This implementation is not guaranteed to catch all possible errors in an email address.
.- Since:
- Validator 1.4
- Version:
- $Revision: 1715080 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final boolean
private static final Pattern
private static final String
private static final EmailValidator
Singleton instance of this class, which doesn't consider local addresses as valid.private static final EmailValidator
Singleton instance of this class, which does consider local addresses valid.private static final EmailValidator
Singleton instance of this class, which does consider local addresses valid.private static final EmailValidator
Singleton instance of this class, which doesn't consider local addresses as valid.private static final Pattern
private static final String
private static final String
private static final long
private static final String
private static final Pattern
private static final String
private static final String
private static final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
EmailValidator
(boolean allowLocal) Protected constructor for subclasses to use.protected
EmailValidator
(boolean allowLocal, boolean allowTld) Protected constructor for subclasses to use. -
Method Summary
Modifier and TypeMethodDescriptionstatic EmailValidator
Returns the Singleton instance of this validator.static EmailValidator
getInstance
(boolean allowLocal) Returns the Singleton instance of this validator, with local validation as required.static EmailValidator
getInstance
(boolean allowLocal, boolean allowTld) Returns the Singleton instance of this validator, with local validation as required.boolean
Checks if a field has a valid e-mail address.protected boolean
isValidDomain
(String domain) Returns true if the domain component of an email address is valid.protected boolean
isValidUser
(String user) Returns true if the user component of an email address is valid.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
SPECIAL_CHARS
- See Also:
-
VALID_CHARS
- See Also:
-
QUOTED_USER
- See Also:
-
WORD
- See Also:
-
EMAIL_REGEX
- See Also:
-
IP_DOMAIN_REGEX
- See Also:
-
USER_REGEX
- See Also:
-
EMAIL_PATTERN
-
IP_DOMAIN_PATTERN
-
USER_PATTERN
-
allowLocal
private final boolean allowLocal -
allowTld
private final boolean allowTld -
EMAIL_VALIDATOR
Singleton instance of this class, which doesn't consider local addresses as valid. -
EMAIL_VALIDATOR_WITH_TLD
Singleton instance of this class, which doesn't consider local addresses as valid. -
EMAIL_VALIDATOR_WITH_LOCAL
Singleton instance of this class, which does consider local addresses valid. -
EMAIL_VALIDATOR_WITH_LOCAL_WITH_TLD
Singleton instance of this class, which does consider local addresses valid.
-
-
Constructor Details
-
EmailValidator
protected EmailValidator(boolean allowLocal, boolean allowTld) Protected constructor for subclasses to use.- Parameters:
allowLocal
- Should local addresses be considered valid?
-
EmailValidator
protected EmailValidator(boolean allowLocal) Protected constructor for subclasses to use.- Parameters:
allowLocal
- Should local addresses be considered valid?
-
-
Method Details
-
getInstance
Returns the Singleton instance of this validator.- Returns:
- singleton instance of this validator.
-
getInstance
Returns the Singleton instance of this validator, with local validation as required.- Parameters:
allowLocal
- Should local addresses be considered valid?- Returns:
- singleton instance of this validator
-
getInstance
Returns the Singleton instance of this validator, with local validation as required.- Parameters:
allowLocal
- Should local addresses be considered valid?- Returns:
- singleton instance of this validator
-
isValid
Checks if a field has a valid e-mail address.
- Parameters:
email
- The value validation is being performed on. Anull
value is considered invalid.- Returns:
- true if the email address is valid.
-
isValidDomain
Returns true if the domain component of an email address is valid.- Parameters:
domain
- being validated, may be in IDN format- Returns:
- true if the email address's domain is valid.
-
isValidUser
Returns true if the user component of an email address is valid.- Parameters:
user
- being validated- Returns:
- true if the user name is valid.
-