Skip to content

Commit

Permalink
Support @positive, @PositiveOrZero, @Negative, @NegativeOrZero Issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
daivanov committed Aug 28, 2020
1 parent 9429541 commit 23551aa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/uk/co/jemos/podam/common/BeanValidationStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,34 @@ public Object getValue(Class<?> attrType, List<Annotation> annotations) throws P
max = new BigDecimal(maxAnno.value()).min(max);
}

Positive positiveAnno = findTypeFromList(annotations, Positive.class);
if (null != positiveAnno) {
isFloat = true;
max = new BigDecimal(Integer.MAX_VALUE);
min = new BigDecimal(1);
}

PositiveOrZero positiveOrZeroAnno = findTypeFromList(annotations, PositiveOrZero.class);
if (null != positiveOrZeroAnno) {
isFloat = true;
max = new BigDecimal(Integer.MAX_VALUE);
min = new BigDecimal(0);
}

Negative negativeAnno = findTypeFromList(annotations, Negative.class);
if (null != negativeAnno) {
isFloat = true;
max = new BigDecimal(-1);
min = new BigDecimal(Integer.MIN_VALUE);
}

NegativeOrZero negativeOrZeroAnno = findTypeFromList(annotations, NegativeOrZero.class);
if (null != negativeOrZeroAnno) {
isFloat = true;
max = new BigDecimal(0);
min = new BigDecimal(Integer.MIN_VALUE);
}

Digits digits = findTypeFromList(annotations, Digits.class);
BigDecimal divisor = null;
if (null != digits) {
Expand Down

0 comments on commit 23551aa

Please sign in to comment.