0

I would like to make sure that totalAmount is greater then 0.
I have following code to in my Java bean:

@NotNull(message = "Total amount must be entered")
@Digits(integer = 8, fraction = 2, message = "Please enter a valid amount less than 99,999,999.99")
@DecimalMin(value = "0.01", message = "Please enter a valid amount more than 0")
private BigDecimal totalAmount;

Unfortunately valdr-bean-validator (tool to use JSR-303 with AngularJS) doesn't support @DecimalMin or @DecimalMax. Is there any other way to create the rule for values greater then zero?

EDIT: please note that totalAmount is BigDecimal

FazoM
  • 4,777
  • 6
  • 43
  • 61

2 Answers2

3

This should do.

@DecimalMin(value = "0", inclusive = false) by default incluside is true

Vaclav Stengl
  • 359
  • 3
  • 8
-1

I couldn't solve it with JSR-303. I finally implemented custom valdr validator.
It is shame that such common case (value equal to zero) is not supported.

FazoM
  • 4,777
  • 6
  • 43
  • 61