Allow me to be a bit more precise.
Code:
public class MyClass {
private BigDecimal quantity;
private BigDecimal maxQuantity;
}
I want to be able to say:
- IF quantity is not null, then quantity must be > 0 AND less or equal to maxQuantity.
- if quantity is null, no requirement for a rule.
I thought of using
Code:
new Rules(MyClass.class) {
protected void initRules() {
add("quantity", ifTrue( present(),
all(new Constraint[] {
required(),
gt(new BigDecimal(0.0)),
gteProperty("maxQuantity", "quantity") }));
However this seems to say that maxQuantity is NOT a property of BigDecimal, but I cannot figure out why it seems to call it on a BigDecimal rather than MyClass???
Could somebody enlighten me? THANKS
Benoit