public class EmailValidator extends Object implements Serializable
Perform email validations.
This class is a Singleton; you can retrieve the instance via the getInstance() method.
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. For example, an address like nobody@noplace.somedog will pass validator, even though there is no TLD "somedog"
.Modifier | Constructor and Description |
---|---|
protected |
EmailValidator(boolean allowLocal)
Protected constructor for subclasses to use.
|
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.
|
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.
|
protected EmailValidator(boolean allowLocal)
allowLocal
- Should local addresses be considered valid?public static EmailValidator getInstance()
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.protected boolean isValidUser(String user)
user
- being validatedCopyright © 2014 OpenEstate. All rights reserved.