Package org.apache.commons.validator

Examples of org.apache.commons.validator.Validator


      final String fieldBeanName) {
    // Add an error to verify the error is passed in..
    final Errors errors = ErrorsFactory.newInstance();
    errors.add("seed", "dude"); //$NON-NLS-1$ //$NON-NLS-2$

    final Validator validator = new Validator(this.validatorResources,
        fieldBeanName);
    // add the name bean to the validator as a resource
    // for the validations to be performed on.
    validator.setParameter(Validator.BEAN_PARAM, testBean);
    validator.setParameter(Globals.ERRORS_KEY, errors);

    // Get results of the validation.
    try {
      validator.validate();
    } catch (final ValidatorException e) {
      fail();
    }
    return errors;
  }
View Full Code Here


   * Method to be called by the CommonsValidatorEvent class. signature will be
   * modified.
   */
  public static void validate(String beanName, Object o, Errors errors) {
    try {
      Validator validator = new Validator(validatorResources, beanName);
      // add the name bean to the validator as a resource
      // for the validations to be performed on.
      validator.setParameter(Validator.BEAN_PARAM, o);
      validator.setParameter(Globals.ERRORS_KEY, errors);

      validator.validate();
    } catch (ValidatorException e) {
      LOGGER.info("Error validating HttpEvent " + beanName + " : " + e); //$NON-NLS-1$ //$NON-NLS-2$
    } catch (IllegalArgumentException e) {
      LOGGER.warn("Error validating: " + e.getMessage()); //$NON-NLS-1$
    }
View Full Code Here

     *
     * @param beanName The name of the bean for which this <code>Validator</code> will be created
     * @see org.apache.commons.validator.Validator
     */
    public Validator getValidator(String beanName, Object bean, Errors errors) {
        Validator validator = new Validator(validatorResources, beanName);
        validator.setParameter(DefaultValidatorFactory.ERRORS_KEY, errors);
        validator.setParameter(Validator.BEAN_PARAM, bean);
        return validator;
    }
View Full Code Here

        MockControl control = MockControl.createControl(Errors.class);

        Errors errors = (Errors) control.getMock();
        Object bean = new Object();

        Validator val = factory.getValidator("fooBean", bean, errors);
        assertSame(val.getParameterValue(Validator.BEAN_PARAM), bean);
        assertSame(val.getParameterValue(DefaultValidatorFactory.ERRORS_KEY), errors);
    }
View Full Code Here

    }

    private Validator getCommonsValidator() {
        ValidatorResources res = new ValidatorResources();
        res.process();
        return new Validator(res);
    }
View Full Code Here

    }

    private Validator getCommonsValidator() {
        ValidatorResources res = new ValidatorResources();
        res.process();
        return new Validator(res);
    }
View Full Code Here

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

        boolean result = FieldChecks.validateValidWhen(bean, validatorAction, field, errors, validator);
        assertTrue(result);
    }
View Full Code Here

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

        boolean result = FieldChecks.validateValidWhen(bean, validatorAction, field, errors, validator);
        assertTrue(result);
    }
View Full Code Here

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

        boolean result = FieldChecks.validateValidWhen(bean, validatorAction, field, errors, validator);
        assertFalse(result);
    }
View Full Code Here

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

        boolean result = FieldChecks.validateValidWhen(bean, validatorAction, field, errors, validator);
        assertTrue(result);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.validator.Validator

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.