added validate method to emailvalidator so it can be used outside faces environment
This commit is contained in:
@ -36,7 +36,6 @@ public class EmailValidator implements Validator {
|
||||
+ "(\\.[A-Za-z]{2,})$";
|
||||
|
||||
private final Pattern pattern;
|
||||
private Matcher matcher;
|
||||
|
||||
public EmailValidator() {
|
||||
pattern = Pattern.compile(EMAIL_PATTERN);
|
||||
@ -44,7 +43,7 @@ public class EmailValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
|
||||
matcher = pattern.matcher(value.toString());
|
||||
Matcher matcher = pattern.matcher(value.toString());
|
||||
if (!matcher.matches()) {
|
||||
// String summary = context.getApplication().evaluateExpressionGet(context, "#{msgs.email_validation_failed}", String.class);
|
||||
// String detail = context.getApplication().evaluateExpressionGet(context, "#{msgs.email_validation_failed_detail}", String.class);
|
||||
@ -57,4 +56,9 @@ public class EmailValidator implements Validator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid(String emailAddress) {
|
||||
Matcher matcher = pattern.matcher(emailAddress);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user