01: package ru.emdev.EmForge.web.validator;
02:
03: import javax.faces.application.FacesMessage;
04: import javax.faces.component.UIComponent;
05: import javax.faces.context.FacesContext;
06: import javax.faces.validator.Validator;
07: import javax.faces.validator.ValidatorException;
08:
09: /** Email Validator
10: *
11: * @author akakunin
12: *
13: */
14: public class EmailValidator implements Validator {
15:
16: public void validate(FacesContext i_context,
17: UIComponent i_component, Object i_value)
18: throws ValidatorException {
19: String email = i_value.toString();
20:
21: org.apache.commons.validator.EmailValidator validator = org.apache.commons.validator.EmailValidator
22: .getInstance();
23:
24: if (!validator.isValid(email)) {
25: throw new ValidatorException(new FacesMessage(
26: "Email format is incorrect",
27: "Email format is incorrect"));
28: }
29:
30: }
31:
32: }
|