br.com.jarch.faces.validator.EmailValidator Maven / Gradle / Ivy
package br.com.jarch.faces.validator;
import br.com.jarch.core.util.BundleUtils;
import br.com.jarch.util.ValidationUtils;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
@FacesValidator("emailValidator")
public class EmailValidator implements Validator {
@Override
public void validate(FacesContext arg0, UIComponent arg1, Object value) {
if (value == null || value.toString().isEmpty())
return;
String enderecoEmail = value.toString();
String[] enderecosEmail = enderecoEmail.split(";");
for (String email : enderecosEmail) {
if (!ValidationUtils.isEmail(email)) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
BundleUtils.messageBundle("label.email"),
BundleUtils.messageBundle("label.emailInvalido"));
throw new ValidatorException(msg);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy