Search in sources :

Example 1 with DecimalMinValidatorForCharSequence

use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForCharSequence in project hibernate-validator by hibernate.

the class MinValidatorForStringTest method testIsValidDecimalMinValidator.

@Test
public void testIsValidDecimalMinValidator() {
    ConstraintAnnotationDescriptor.Builder<DecimalMin> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMin.class);
    descriptorBuilder.setAttribute("value", "1500E-2");
    descriptorBuilder.setMessage("{validator.min}");
    DecimalMin m = descriptorBuilder.build().getAnnotation();
    DecimalMinValidatorForCharSequence constraint = new DecimalMinValidatorForCharSequence();
    constraint.initialize(m);
    testMinValidator(constraint, true);
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) DecimalMinValidatorForCharSequence(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForCharSequence) DecimalMin(jakarta.validation.constraints.DecimalMin) Test(org.testng.annotations.Test)

Example 2 with DecimalMinValidatorForCharSequence

use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForCharSequence in project hibernate-validator by hibernate.

the class MinValidatorForStringTest method testIsValidDecimalMinExclusive.

@Test
@TestForIssue(jiraKey = "HV-256")
public void testIsValidDecimalMinExclusive() {
    boolean inclusive = false;
    ConstraintAnnotationDescriptor.Builder<DecimalMin> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMin.class);
    descriptorBuilder.setAttribute("value", "1500E-2");
    descriptorBuilder.setAttribute("inclusive", inclusive);
    descriptorBuilder.setMessage("{validator.min}");
    DecimalMin m = descriptorBuilder.build().getAnnotation();
    DecimalMinValidatorForCharSequence constraint = new DecimalMinValidatorForCharSequence();
    constraint.initialize(m);
    testMinValidator(constraint, inclusive);
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) DecimalMinValidatorForCharSequence(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForCharSequence) DecimalMin(jakarta.validation.constraints.DecimalMin) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Aggregations

DecimalMin (jakarta.validation.constraints.DecimalMin)2 DecimalMinValidatorForCharSequence (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForCharSequence)2 ConstraintAnnotationDescriptor (org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor)2 Test (org.testng.annotations.Test)2 TestForIssue (org.hibernate.validator.testutil.TestForIssue)1