public class EmailValidator extends Object implements 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.
.Modifier | Constructor and Description |
---|---|
protected |
EmailValidator(boolean allowLocal)
Protected constructor for subclasses to use.
|
protected |
EmailValidator(boolean allowLocal,
boolean allowTld)
Protected constructor for subclasses to use.
|
|
EmailValidator(boolean allowLocal,
boolean allowTld,
DomainValidator domainValidator)
constructor for creating instances with the specified domainValidator
|
Modifier and Type | Method and Description |
---|---|
static EmailValidator |
getInstance()
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 |
isValid(String email)
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.
|
public EmailValidator(boolean allowLocal, boolean allowTld, DomainValidator domainValidator)
allowLocal
- Should local addresses be considered valid?allowTld
- Should TLDs be allowed?domainValidator
- allow override of the DomainValidator.
The instance must have the same allowLocal setting.protected EmailValidator(boolean allowLocal, boolean allowTld)
allowLocal
- Should local addresses be considered valid?allowTld
- Should TLDs be allowed?protected EmailValidator(boolean allowLocal)
allowLocal
- Should local addresses be considered valid?public static EmailValidator getInstance()
public static EmailValidator getInstance(boolean allowLocal, boolean allowTld)
allowLocal
- Should local addresses be considered valid?allowTld
- Should TLDs be allowed?public static EmailValidator getInstance(boolean allowLocal)
allowLocal
- Should local addresses be considered valid?public boolean isValid(String email)
Checks if a field has a valid e-mail address.
email
- The value validation is being performed on. A null
value is considered invalid.protected boolean isValidDomain(String domain)
domain
- being validated, may be in IDN formatprotected boolean isValidUser(String user)
user
- being validatedCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.