Package br.com.caelum.stella.validation

Examples of br.com.caelum.stella.validation.CPFValidator


    /**
     * @see org.hibernate.validator.Validator#initialize(java.lang.annotation.Annotation)
     */
    public void initialize(CPF cpf) {
        AnnotationMessageProducer messageProducer = new AnnotationMessageProducer(cpf);
        stellaValidator = new CPFValidator(messageProducer, cpf.formatted());
    }
View Full Code Here


import br.com.caelum.stella.validation.CPFValidator;

public class SimpleExample {
  public static void main(String[] args) {
  String cpf = "867.554.707-24";
  for(ValidationMessage error : new CPFValidator().invalidMessagesFor(cpf)) {
    System.out.println(error.getMessage());
  }
 
  new CPFValidator().assertValid("867.554.707-24");
 
  }
View Full Code Here

import br.com.caelum.stella.validation.InvalidStateException;

public class SimpleExample {
  public static void main(String[] args) {
  String cpf = "867.554.707-24";
  for(ValidationMessage error : new CPFValidator().invalidMessagesFor(cpf)) {
    System.out.println(error.getMessage());
  }
 
  new CPFValidator().assertValid("867.554.707-24");
 
  }
View Full Code Here

    }

    public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
        ResourceBundle bundle = resourceBundleFinder.getForCurrentLocale(facesContext);
        ResourceBundleMessageProducer producer = new ResourceBundleMessageProducer(bundle);
        CPFValidator validator = new CPFValidator(producer, formatted);

        try {
            validator.assertValid(value.toString());
        }
        catch (InvalidStateException e) {
            List<ValidationMessage> messages = e.getInvalidMessages();
            String firstErrorMessage = messages.remove(0).getMessage();
            registerAllMessages(facesContext, uiComponent, messages);
View Full Code Here

    String bundleName = application.getMessageBundle();
    Locale locale = facesContext.getViewRoot().getLocale();
    ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);

    ResourceBundleMessageProducer producer = new ResourceBundleMessageProducer(bundle);
    CPFValidator validator = new CPFValidator(producer, formatted);

    try {
      validator.assertValid(value.toString());
    }
    catch (InvalidStateException e){
      List<ValidationMessage> messages = e.getInvalidMessages();
      String firstErrorMessage = messages.remove(0).getMessage();
      registerAllMessages(facesContext, uiComponent, messages);
View Full Code Here

    }

    public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
        ResourceBundle bundle = resourceBundleFinder.getForCurrentLocale(facesContext);
        ResourceBundleMessageProducer producer = new ResourceBundleMessageProducer(bundle);
        CPFValidator validator = new CPFValidator(producer, formatted);

        try {
            validator.assertValid(value.toString());
        } catch (InvalidStateException e) {
            List<ValidationMessage> messages = e.getInvalidMessages();
            String firstErrorMessage = messages.remove(0).getMessage();
            registerAllMessages(facesContext, uiComponent, messages);
            throw new ValidatorException(new FacesMessage(firstErrorMessage));
View Full Code Here

public class StellaCPFValidator implements ConstraintValidator<CPF, String> {
  private CPFValidator stellaValidator;

  public void initialize(CPF cpf) {
    AnnotationMessageProducer messageProducer = new AnnotationMessageProducer(cpf);
    stellaValidator = new CPFValidator(messageProducer, cpf.formatted());
  }
View Full Code Here

     * @return se o número do CPF é valido.
     *
     * @see CPFValidator
     */
  public boolean isValido() {
    return new CPFValidator().invalidMessagesFor(numero).isEmpty();
  }
View Full Code Here

    }

    public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
        ResourceBundle bundle = resourceBundleFinder.getForCurrentLocale(facesContext);
        ResourceBundleMessageProducer producer = new ResourceBundleMessageProducer(bundle);
        CPFValidator validator = new CPFValidator(producer, formatted);

        try {
            validator.assertValid(value.toString());
        } catch (InvalidStateException e) {
            List<ValidationMessage> messages = e.getInvalidMessages();
            String firstErrorMessage = messages.remove(0).getMessage();
            registerAllMessages(facesContext, uiComponent, messages);
            throw new ValidatorException(new FacesMessage(firstErrorMessage));
View Full Code Here

    }

    public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
        ResourceBundle bundle = resourceBundleFinder.getForCurrentLocale(facesContext);
        ResourceBundleMessageProducer producer = new ResourceBundleMessageProducer(bundle);
        CPFValidator validator = new CPFValidator(producer, formatted);

        try {
            validator.assertValid(value.toString());
        } catch (InvalidStateException e) {
            List<ValidationMessage> messages = e.getInvalidMessages();
            String firstErrorMessage = messages.remove(0).getMessage();
            registerAllMessages(facesContext, uiComponent, messages);
            throw new ValidatorException(new FacesMessage(firstErrorMessage));
View Full Code Here

TOP

Related Classes of br.com.caelum.stella.validation.CPFValidator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.