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

Examples of org.hibernate.validator.internal.constraintvalidators.bv.PatternValidator


    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    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


  public void testIsValidForCharSequence() {
    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 ) );
  }
View Full Code Here

    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    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 ) );
    assertTrue( constraint.isValid( "a b c foo", null ) );
  }
View Full Code Here

    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    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

Related Classes of org.hibernate.validator.internal.constraintvalidators.bv.PatternValidator

Copyright © 2018 www.massapicom. 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.