public class EmailValidator extends Object implements ConstraintValidator<Email,String>
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.
| Constructor and Description |
|---|
EmailValidator() |
| Modifier and Type | Method and Description |
|---|---|
void |
initialize(Email annotation)
Initialize the validator in preparation for isValid calls.
|
boolean |
isValid(String value,
ConstraintValidatorContext context)
Implement the validation logic.
|
public void initialize(Email annotation)
ConstraintValidatorinitialize in interface ConstraintValidator<Email,String>annotation - annotation instance for a given constraint declarationpublic boolean isValid(String value, ConstraintValidatorContext context)
ConstraintValidatorvalue must not be altered.
This method can be accessed concurrently, thread-safety must be ensured
by the implementation.isValid in interface ConstraintValidator<Email,String>value - object to validatecontext - context in which the constraint is evaluatedvalue does not pass the constraintCopyright © 2012 JBoss by Red Hat. All Rights Reserved.