Package org.hibernate.validator.internal.constraintvalidators.bv

Examples of org.hibernate.validator.internal.constraintvalidators.bv.PatternValidator.initialize()


    descriptor.setValue( "regexp", "foobar" );
    descriptor.setValue( "message", "pattern does not match" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );

    assertTrue( constraint.isValid( null, null ) );
    assertFalse( constraint.isValid( "", null ) );
    assertFalse( constraint.isValid( "bla bla", null ) );
    assertFalse( constraint.isValid( "This test is not foobar", null ) );
View Full Code Here


    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    descriptor.setValue( "regexp", "char sequence" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );

    assertTrue( constraint.isValid( new MyCustomStringImpl( "char sequence" ), null ) );
  }

  @Test
View Full Code Here

    descriptor.setValue( "regexp", "|^.*foo$" );
    descriptor.setValue( "message", "pattern does not match" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );

    assertTrue( constraint.isValid( null, null ) );
    assertTrue( constraint.isValid( "", null ) );
    assertFalse( constraint.isValid( "bla bla", null ) );
    assertTrue( constraint.isValid( "foo", null ) );
View Full Code Here

    descriptor.setValue( "regexp", "(unbalanced parentheses" );
    descriptor.setValue( "message", "pattern does not match" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    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.