30 lines
1009 B
Plaintext
Executable File
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")));
|
|
}
|
|
}
|
|
|
|
}
|