Package javax.validation

Examples of javax.validation.Validator.validate()


                return;
            }
            if (editFromInplace) {
                // We need validate image name manually
                Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
                Set<ConstraintViolation<Image>> constraintViolations = validator.validate(image);
                if (constraintViolations.size() > 0) {
                    for (ConstraintViolation<Image> cv : constraintViolations) {
                        error.fire(new ErrorEvent("Constraint violation", cv.getMessage()));
                    }
                    // If error occurred we need refresh album to display correct value in inplaceInput
View Full Code Here


                return;
            }
            if (editFromInplace) {
                // We need validate shelf name manually
                Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
                Set<ConstraintViolation<Shelf>> constraintViolations = validator.validate(shelf);
                if (constraintViolations.size() > 0) {
                    for (ConstraintViolation<Shelf> cv : constraintViolations) {
                        error.fire(new ErrorEvent("Constraint violation", cv.getMessage()));
                    }
                    // If error occured we need refresh album to display correct value in inplaceInput
View Full Code Here

            }
            // also try validating using Bean Validation if there is a Validator available in the context.
            try {
                Validator validator = (Validator)beanContext.getJndiContext().lookup("comp/Validator");

                Set generalSet = validator.validate(activationSpec);
                if (!generalSet.isEmpty()) {
                    throw new ConstraintViolationException("Constraint violation for ActivationSpec " + activationSpecClass.getName(), generalSet);
                }
            } catch (NamingException e) {
                logger.debug("No Validator bound to JNDI context");
View Full Code Here

    Validator v = Validation.buildDefaultValidatorFactory().getValidator();

    this.dmin = 922392239223.05;
    this.dmax = 922392239223.08;

    Set<ConstraintViolation<DecimalMinMaxValidatorsTest>> res = v.validate(this);
    assertFalse("Min validation failed", res.isEmpty());
  }

  public void testDecimalMaxValue() {
    Validator v = Validation.buildDefaultValidatorFactory().getValidator();
View Full Code Here

    Validator v = Validation.buildDefaultValidatorFactory().getValidator();

    this.dmin = Double.MAX_VALUE;
    this.dmax = 922392239223.1;

    Set<ConstraintViolation<DecimalMinMaxValidatorsTest>> res = v.validate(this);
    assertFalse("Max validation failed", res.isEmpty());
  }


}
View Full Code Here

    this.min = 9223372036854775806l;
    this.max = 0l;

    // Current min value is smaller, should fail, but it doesn't
    Set<ConstraintViolation<MinMaxValidatorsForNumberTest>> res = v.validate(this);
    assertFalse("Min validation failed", res.isEmpty());
  }

  public void testMaxBoundaryValue() {
    Validator v = Validation.buildDefaultValidatorFactory().getValidator();
View Full Code Here

    this.min = Long.MAX_VALUE;
    this.max = 9223372036854775807l;

    // Current max value is bigger, should fail, but it doesn't
    Set<ConstraintViolation<MinMaxValidatorsForNumberTest>> res = v.validate(this);
    assertFalse("Max validation failed", res.isEmpty());
  }


}
View Full Code Here

        customer.setCustomerId("id-1");
        customer.setFirstName("Mary");
        customer.setLastName("Do");
        customer.setPassword("12345");

        Assert.assertEquals(0, validator.validate(customer).size());

        customer.setEmailAddress("some@invalid@address");
        Assert.assertEquals(1, validator.validate(customer).size());

        customer.setEmailAddress("some.valid-012345@address_at-test.org");
View Full Code Here

        customer.setPassword("12345");

        Assert.assertEquals(0, validator.validate(customer).size());

        customer.setEmailAddress("some@invalid@address");
        Assert.assertEquals(1, validator.validate(customer).size());

        customer.setEmailAddress("some.valid-012345@address_at-test.org");
        Assert.assertEquals(0, validator.validate(customer).size());
    }
View Full Code Here

        customer.setEmailAddress("some@invalid@address");
        Assert.assertEquals(1, validator.validate(customer).size());

        customer.setEmailAddress("some.valid-012345@address_at-test.org");
        Assert.assertEquals(0, validator.validate(customer).size());
    }


    public static Test suite() {
        return new TestSuite(EmailValidatorTest.class);
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.