maia_modificado/registro/.svn/pristine/9f/9f7d6c1119bea7a885e20a1c258...

30 lines
1009 B
Plaintext
Executable File

package com.fp.armas.portal.validator;
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;
import com.fp.armas.portal.web.PortalWebResources;
/**
* Valida que un número celular comience con 09
* @author dcruz
*
*/
@FacesValidator(value="celularValidator")
public class CelularValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component,
Object value) throws ValidatorException {
String valueString = value != null ? value.toString() : null;
if(value != null && valueString.length() > 2 && !valueString.startsWith("09")){
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, PortalWebResources.getString("error.celular.incorrecto"), PortalWebResources.getString("error.celular.incorrecto")));
}
}
}