Examples of validateValue()


Examples of javax.validation.Validator.validateValue()

    Property property = getProperty();

    // validate the value using the bean validator

    Set<?> violations = validator.validateValue(property.getOwner(), property.getName(),
      validatable.getValue(), getGroups());

    // iterate over violations and report them

    for (ConstraintViolation<?> violation : (Set<ConstraintViolation<?>>)violations)
View Full Code Here

Examples of javax.validation.Validator.validateValue()

        final ValidationInfo validationInfo = getValidationInfo(beanValidationContext, currentProperty, validator);
        final PropertyDescriptor propertyDescriptor = validationInfo.getPropertyDescriptor();

        if (propertyDescriptor == null) return;

        final Set<ConstraintViolation<Object>> violations = validator.validateValue(
                (Class<Object>) validationInfo.getBeanType(), validationInfo.getPropertyName(),
                value, beanValidationGroupSource.get());

        if (violations.isEmpty())
        {
View Full Code Here

Examples of javax.validation.Validator.validateValue()

        if (validator == null || proposed == null || identifierHolder == null) {
            return null;
        }
       
        final String memberName = identifierHolder.getIdentifier().getMemberName();
        Set<InvalidConstraint<?>> constraints = validator.validateValue(memberName, proposed);
        return asString(memberName, constraints);
    }

    private Validator<?> getTargetValidator(final ValidityContext<? extends ValidityEvent> validityContext) {
        final ObjectAdapter targetNO = validityContext.getTarget();
View Full Code Here

Examples of javax.validation.Validator.validateValue()

    }

    public void testValidateValue() {
        Validator validator = getValidator();
        assertTrue(
              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
        assertFalse(validator.validateValue(Book.class, "subtitle",
              "123456789098765432123412345678909876543212341234564567890987654321234",
              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
View Full Code Here

Examples of javax.validation.Validator.validateValue()

    public void testValidateValue() {
        Validator validator = getValidator();
        assertTrue(
              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
        assertFalse(validator.validateValue(Book.class, "subtitle",
              "123456789098765432123412345678909876543212341234564567890987654321234",
              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
        // tests for issue 22: validation of unknown field cause ValidationException
View Full Code Here

Examples of javax.validation.Validator.validateValue()

              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
        assertFalse(validator.validateValue(Book.class, "subtitle",
              "123456789098765432123412345678909876543212341234564567890987654321234",
              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
        // tests for issue 22: validation of unknown field cause ValidationException
        try {
            validator.validateValue(Book.class, "unknownProperty", 4);
            fail("unknownProperty not detected");
        } catch (IllegalArgumentException ex) {
View Full Code Here

Examples of javax.validation.Validator.validateValue()

              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
        // tests for issue 22: validation of unknown field cause ValidationException
        try {
            validator.validateValue(Book.class, "unknownProperty", 4);
            fail("unknownProperty not detected");
        } catch (IllegalArgumentException ex) {
            // OK
            assertEquals(
                  "unknown property 'unknownProperty' in org.apache.bval.jsr303.example.Book",
View Full Code Here

Examples of javax.validation.Validator.validateValue()

    Property property = getProperty();

    // validate the value using the bean validator

    Set<?> violations = validator.validateValue(property.getOwner(), property.getName(),
      validatable.getValue(), getGroups());

    // iterate over violations and report them

    for (ConstraintViolation<?> violation : (Set<ConstraintViolation<?>>)violations)
View Full Code Here

Examples of javax.validation.Validator.validateValue()

          // Se houver um validador anexado à propriedade alterada, executa o validador sobre
          // o novo valor.
          Validator validator = getDefaultValidator();
          if (validator != null) {
            Set<?> violations = validator.validateValue(managedType.getType(), propertyName, newValue);
            if (violations.size() > 0) {
              StringBuffer errorBuffer = new StringBuffer();
              for (Object objectViolation : violations) {
                ConstraintViolation<?> violation = (ConstraintViolation<?>) objectViolation;
                errorBuffer.append(violation.getMessage()).append('\r').append('\n');
View Full Code Here

Examples of javax.validation.Validator.validateValue()

   
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(currentProperty);
   
    if(propertyDescriptor == null) return;
   
    final Set<ConstraintViolation<Object>> violations = validator.validateValue(
            (Class<Object>) beanValidationContext.getBeanType(), currentProperty,
            value, beanValidationGroupSource.get());
   
    if (violations.isEmpty())
    {
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.