The specification of a valid email can be found in RFC 2822 and one can come up with a regular expression matching all valid email addresses as per specification. However, as this article discusses it is not necessarily practical to implement a 100% compliant email validator. This implementation is a trade-off trying to match most email while ignoring for example emails with double quotes or comments.
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| private static final Pattern | LOCAL_PART_PATTERN
Regular expression for the local part of an email address (everything before '@') |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isValid(CharSequence
object to validate value, ConstraintValidatorContext context in which the constraint is evaluated context)Implements jakarta. |
| private boolean |
| LOCAL_PART_ATOM | back to summary |
|---|---|
| private static final String LOCAL_PART_ATOM | |
| LOCAL_PART_INSIDE_QUOTES_ATOM | back to summary |
|---|---|
| private static final String LOCAL_PART_INSIDE_QUOTES_ATOM | |
| LOCAL_PART_PATTERN | back to summary |
|---|---|
| private static final Pattern LOCAL_PART_PATTERN Regular expression for the local part of an email address (everything before '@') | |
| MAX_LOCAL_PART_LENGTH | back to summary |
|---|---|
| private static final int MAX_LOCAL_PART_LENGTH | |
| AbstractEmailValidator | back to summary |
|---|---|
| public AbstractEmailValidator() | |
| isValid | back to summary |
|---|---|
| public boolean isValid(CharSequence value, ConstraintValidatorContext context) Implements jakarta. Doc from jakarta. Implements the validation logic.
The state of This method can be accessed concurrently, thread-safety must be ensured by the implementation.
| |
| isValidEmailLocalPart | back to summary |
|---|---|
| private boolean isValidEmailLocalPart(String localPart) | |