Package org.hibernate.validator.internal.constraintvalidators.hv

Examples of org.hibernate.validator.internal.constraintvalidators.hv.LengthValidator.initialize()


    descriptor.setValue( "min", 1 );
    descriptor.setValue( "max", 3 );
    descriptor.setValue( "message", "{validator.length}" );
    Length l = AnnotationFactory.create( descriptor );
    LengthValidator constraint = new LengthValidator();
    constraint.initialize( l );
    assertTrue( constraint.isValid( null, null ) );
    assertFalse( constraint.isValid( "", null ) );
    assertTrue( constraint.isValid( "f", null ) );
    assertTrue( constraint.isValid( "fo", null ) );
    assertTrue( constraint.isValid( "foo", null ) );
View Full Code Here


    AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
    descriptor.setValue( "min", 1 );
    descriptor.setValue( "max", 3 );
    Length l = AnnotationFactory.create( descriptor );
    LengthValidator constraint = new LengthValidator();
    constraint.initialize( l );
    assertTrue( constraint.isValid( new MyCustomStringImpl( "foo" ), null ) );
    assertFalse( constraint.isValid( new MyCustomStringImpl( "foobar" ), null ) );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
View Full Code Here

    descriptor.setValue( "max", 1 );
    descriptor.setValue( "message", "{validator.length}" );
    Length p = AnnotationFactory.create( descriptor );

    LengthValidator constraint = new LengthValidator();
    constraint.initialize( p );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNegativeMaxValue() {
    AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
View Full Code Here

    descriptor.setValue( "max", -1 );
    descriptor.setValue( "message", "{validator.length}" );
    Length p = AnnotationFactory.create( descriptor );

    LengthValidator constraint = new LengthValidator();
    constraint.initialize( p );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNegativeLength() {
    AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
View Full Code Here

    descriptor.setValue( "max", 4 );
    descriptor.setValue( "message", "{validator.length}" );
    Length p = AnnotationFactory.create( descriptor );

    LengthValidator constraint = new LengthValidator();
    constraint.initialize( p );
  }
}
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.