Class EmailValidator
java.lang.Object
com.dlsc.gemsfx.util.EmailValidator
Validates whether a string is a well-formed email address.
The check covers the common subset of RFC 5321 / 5322:
local-part@domain, where:
- The local part may contain letters, digits, and the characters
!#$%&'*+/=?^_`{|}~-, with internal dots allowed between non-dot segments (dots are not permitted at the start or end, nor consecutively). - The domain consists of dot-separated labels. Each label may contain letters, digits, and hyphens, but must start and end with a letter or digit.
- The top-level domain must consist of at least two alphabetic characters.
- The total address length must not exceed 254 characters (RFC 5321 §4.5.3).
This class is intentionally minimal. More complex formats (IP-address literals, quoted local parts, …) are not supported.
Use getInstance() to obtain the shared, stateless singleton.
-
Method Summary
Modifier and TypeMethodDescriptionstatic EmailValidatorReturns the shared singleton instance.booleanReturnstrueifemailis a well-formed address according to the rules described in the class Javadoc.
-
Method Details
-
getInstance
Returns the shared singleton instance.- Returns:
- the shared singleton instance
-
isValid
Returnstrueifemailis a well-formed address according to the rules described in the class Javadoc.- Parameters:
email- the address to check;nullalways yieldsfalse- Returns:
trueif the address is valid
-