Package javax.validation

Examples of javax.validation.Validator.validate()


      DEFAULT_BUNDLE_KEY + ".String", DEFAULT_BUNDLE_KEY);

    // test with a valid password
    bean.setPassword("aValidPassword1234");

    constraintViolations = validator.validate(bean);
    assertEquals(0, constraintViolations.size());
  }

  /**
   * Checks that validation error has the expected keys as bundle keys, in the order they are
View Full Code Here


        // if we have a validator factory at this point, then validate
        // the resource adaptor instance
        if (validatorFactory != null) {
            Validator validator = validatorFactory.getValidator();

            Set generalSet = validator.validate(managedConnectionFactory);
            if (!generalSet.isEmpty()) {
                throw new ConstraintViolationException("Constraint violation for ManagedConnectionFactory " + managedConnectionFactoryClass, generalSet);
            }
        }
        //register with resource adapter
View Full Code Here

    Validator validator = factory.usingContext()
        .traversableResolver( tr )
        .getValidator();
    final Class<?>[] groups = groupsPerOperation.get( operation );
    if ( groups.length > 0 ) {
      final Set<ConstraintViolation<T>> constraintViolations = validator.validate( object, groups );
      if ( constraintViolations.size() > 0 ) {
        Set<ConstraintViolation<?>> propagatedViolations =
            new HashSet<ConstraintViolation<?>>( constraintViolations.size() );
        Set<String> classNames = new HashSet<String>();
        for ( ConstraintViolation<?> violation : constraintViolations ) {
View Full Code Here

    Validator validator = factory.usingContext()
        .traversableResolver( tr )
        .getValidator();
    final Class<?>[] groups = groupsPerOperation.get( operation );
    if ( groups.length > 0 ) {
      final Set<ConstraintViolation<T>> constraintViolations = validator.validate( object, groups );
      if ( constraintViolations.size() > 0 ) {
        Set<ConstraintViolation<?>> propagatedViolations =
            new HashSet<ConstraintViolation<?>>( constraintViolations.size() );
        Set<String> classNames = new HashSet<String>();
        for ( ConstraintViolation<?> violation : constraintViolations ) {
View Full Code Here

    Validator validator = factory.usingContext()
        .traversableResolver( tr )
        .getValidator();
    final Class<?>[] groups = groupsPerOperation.get( operation );
    if ( groups.length > 0 ) {
      final Set<ConstraintViolation<T>> constraintViolations = validator.validate( object, groups );
      if ( constraintViolations.size() > 0 ) {
        Set<ConstraintViolation<?>> propagatedViolations =
            new HashSet<ConstraintViolation<?>>( constraintViolations.size() );
        Set<String> classNames = new HashSet<String>();
        for ( ConstraintViolation<?> violation : constraintViolations ) {
View Full Code Here

    DefaultViolationTranslator translator = new DefaultViolationTranslator();

    // test with a too short password
    BeanWithPassword bean = new BeanWithPassword("short");

    Set<ConstraintViolation<BeanWithPassword>> constraintViolations = validator.validate(bean);
    assertEquals(1, constraintViolations.size());

    @SuppressWarnings("unchecked")
    ConstraintViolation<BeanWithPassword> shortViolation = (ConstraintViolation<BeanWithPassword>)constraintViolations
      .toArray()[0];
View Full Code Here

    checkErrorBundleKeys(error, DEFAULT_BUNDLE_KEY + ".String", DEFAULT_BUNDLE_KEY);

    // test with a password containing non-word chars
    bean.setPassword("notWord&%$£");

    constraintViolations = validator.validate(bean);
    assertEquals(1, constraintViolations.size());

    @SuppressWarnings("unchecked")
    ConstraintViolation<BeanWithPassword> nonWordviolation = (ConstraintViolation<BeanWithPassword>)constraintViolations.toArray()[0];
View Full Code Here

      DEFAULT_BUNDLE_KEY + ".String", DEFAULT_BUNDLE_KEY);

    // test with a valid password
    bean.setPassword("aValidPassword1234");

    constraintViolations = validator.validate(bean);
    assertEquals(0, constraintViolations.size());
  }

  /**
   * Checks that validation error has the expected keys as bundle keys, in the order they are
View Full Code Here

    ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
    Validator validator = vf.getValidator();

    Address address = new Address("233 Spring Street", "New York", "NY", "DummyZip", "USA");

    Set<ConstraintViolation<Address>> violations = validator.validate(address);
    assertEquals(1, violations.size());

    vf.close();
  }
}
View Full Code Here

                return;
            }
            if (editFromInplace) {
                // We need validate album name manually
                Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
                Set<ConstraintViolation<Album>> constraintViolations = validator.validate(album);
                if (constraintViolations.size() > 0) {
                    for (ConstraintViolation<Album> 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

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.