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

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


    descriptor.setValue( "integer", -1 );
    descriptor.setValue( "fraction", 1 );
    descriptor.setValue( "message", "{validator.digits}" );
    Digits p = AnnotationFactory.create( descriptor );

    DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
    constraint.initialize( p );
  }
View Full Code Here


    descriptor.setValue( "integer", 1 );
    descriptor.setValue( "fraction", -1 );
    descriptor.setValue( "message", "{validator.digits}" );
    Digits p = AnnotationFactory.create( descriptor );

    DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
    constraint.initialize( p );
  }
View Full Code Here

    descriptor.setValue( "integer", 12 );
    descriptor.setValue( "fraction", 3 );
    descriptor.setValue( "message", "{validator.digits}" );
    Digits p = AnnotationFactory.create( descriptor );

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

    assertTrue( constraint.isValid( 0.001d, null ) );
    assertTrue( constraint.isValid( 0.00100d, null ) );
    assertFalse( constraint.isValid( 0.0001d, null ) );
  }
View Full Code Here

    descriptor.setValue( "integer", 5 );
    descriptor.setValue( "fraction", 2 );
    descriptor.setValue( "message", "{validator.digits}" );
    Digits p = AnnotationFactory.create( descriptor );

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


    assertTrue( constraint.isValid( null, null ) );
    assertTrue( constraint.isValid( Byte.valueOf( "0" ), null ) );
    assertTrue( constraint.isValid( Double.valueOf( "500.2" ), null ) );

    assertTrue( constraint.isValid( new BigDecimal( "-12345.12" ), null ) );
    assertFalse( constraint.isValid( new BigDecimal( "-123456.12" ), null ) );
    assertFalse( constraint.isValid( new BigDecimal( "-123456.123" ), null ) );
    assertFalse( constraint.isValid( new BigDecimal( "-12345.123" ), null ) );
    assertFalse( constraint.isValid( new BigDecimal( "12345.123" ), null ) );

    assertTrue( constraint.isValid( Float.valueOf( "-000000000.22" ), null ) );
    assertFalse( constraint.isValid( Integer.valueOf( "256874" ), null ) );
    assertFalse( constraint.isValid( Double.valueOf( "12.0001" ), null ) );
  }
View Full Code Here

    descriptor.setValue( "integer", 0 );
    descriptor.setValue( "fraction", 0 );
    descriptor.setValue( "message", "{validator.digits}" );
    Digits p = AnnotationFactory.create( descriptor );

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


    assertTrue( constraint.isValid( null, null ) );
    assertFalse( constraint.isValid( Byte.valueOf( "0" ), null ) );
    assertFalse( constraint.isValid( Double.valueOf( "500.2" ), null ) );
  }
View Full Code Here

TOP

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

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.