01: package nl.knowlogy.validation.validators;
02:
03: import nl.knowlogy.validation.ErrorCodes;
04:
05: public class EmailValidator extends PatternValidator {
06:
07: private static final String VALID_EMAIL_PATTERN =
08: //"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$";
09: "^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\\-+)|([A-Za-z0-9]+\\.+)|([A-Za-z0-9]+\\++))*[A-Za-z0-9]+@((\\w+\\-+)|(\\w+\\.))*\\w{1,63}\\.[a-zA-Z]{2,6}$";
10:
11: public EmailValidator(String propertyName) {
12: super (propertyName, VALID_EMAIL_PATTERN);
13: }
14:
15: public EmailValidator(String propertyName, String message) {
16: super (propertyName, VALID_EMAIL_PATTERN, message);
17: }
18:
19: public String getDefaultErrorCode() {
20:
21: return ErrorCodes.INVALID_EMAIL_ADDRESS;
22: }
23:
24: }
|