Package org.springframework.validation

Examples of org.springframework.validation.Validator.validate()


        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("appCtxt.xml", getClass());
        Validator validator = (Validator)context.getBean("validator");

        TeztBean1 bean = new TeztBean1();
        BindException errors = new BindException(bean, "bean");
        validator.validate(bean, errors);
        assertTrue(errors.hasErrors());
        assertTrue(errors.hasFieldErrors("name"));

        bean = new TeztBean1("test");
        errors = new BindException(bean, "bean");
View Full Code Here


        assertTrue(errors.hasErrors());
        assertTrue(errors.hasFieldErrors("name"));

        bean = new TeztBean1("test");
        errors = new BindException(bean, "bean");
        validator.validate(bean, errors);
        assertFalse(errors.hasErrors());

    }

    public void testValidatorRef_WhenNotDeployedInApplicationContext() throws Exception {
View Full Code Here

        person.setLifeCycleBean(lifeCycleBean);
        person.setFirstName("FN");

        Validator validator = (Validator) appCtx.getBean("testCustomFunctions");
        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertTrue(lifeCycleBean.isApplicationContextSet());
        assertTrue(lifeCycleBean.isApplicationEventPublisher());
        assertTrue(lifeCycleBean.isBeanFactorySet());
        assertTrue(lifeCycleBean.isMessageSourceSet());
View Full Code Here

        person.setLifeCycleBean(lifeCycleBean);
        person.setFirstName("FN");

        Validator validator = (Validator) appCtx.getBean("testCustomFunctionsFromApplicationContext");
        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertTrue(lifeCycleBean.isApplicationContextSet());
        assertTrue(lifeCycleBean.isApplicationEventPublisher());
        assertTrue(lifeCycleBean.isBeanFactorySet());
        assertTrue(lifeCycleBean.isMessageSourceSet());
View Full Code Here

        person.setFirstName("FN");
        person.setFirstName("LN");

        Validator validator = (Validator) appCtx.getBean("testFunctionFromApplicationContext");
        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertTrue(errors.hasFieldErrors("firstName"));
    }

    public void testPersonValidator() {
View Full Code Here

        Map map = new HashMap();
        map.put("name", "Steven");
        map.put("passwd", "pas");
        person.setForm(map);
        Errors errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertFalse(errors.hasFieldErrors("form[name]"));
        assertTrue(errors.hasFieldErrors("form[passwd]"));
    }
View Full Code Here

     */
    protected void applyCustomValidator(BeanValidationConfiguration configuration, Object obj, Errors errors) {
        Validator validator = configuration.getCustomValidator();
        if (validator != null) {
            if (validator.supports(obj.getClass())) {
                validator.validate(obj, errors);
            }
        }
    }

}
View Full Code Here

     */
    public void validate(Object obj, Errors errors) {
        for (Iterator i = validators.iterator(); i.hasNext();) {
            Validator validator = (Validator) i.next();
            if (validator.supports(obj.getClass())) {
                validator.validate(obj, errors);
            }
        }
    }

    /**
 
View Full Code Here

    for (Iterator iter = validatorsMap.keySet().iterator(); iter.hasNext();) {
      Class tmpClazz = (Class)iter.next();
      Validator validator = (Validator)validatorsMap.get(tmpClazz);
     
      if (tmpClazz.isAssignableFrom(clazz)) {
        validator.validate(target, errors);
      }
    }   
  }
 
  public void setErrorsToRuntimeExceptionTransformer(ErrorsToRuntimeExceptionTransformer transformer) {
View Full Code Here

     */
    public void validate(Object obj, Errors errors) {
        for (Iterator i = validators.iterator(); i.hasNext();) {
            Validator validator = (Validator)i.next();
            if (validator.supports(obj.getClass())) {
                validator.validate(obj, errors);
            }
        }
    }

    /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.