@Digits (jakarta.validation.constraints)
The @jakarta.validation.constraints.Digits annotation is recognized by Apache Causeway as a means to specify the precision for properties and action parameters of type java.math.BigDecimal.
For example:
import jakarta.persistence.Column;
import jakarta.validation.constraints.Digits;
import lombok.Getter;
@Column(
scale=2 (1)
)
@Digits(
integer=10,
fraction=2 (2)
)
@Getter
public void setCost(final BigDecimal cost) {
this.cost = cost!=null
? cost.setScale(2, BigDecimal.ROUND_HALF_EVEN) (3)
:null;
}
| 1 | the ˜@Column#scale attribute must be … |
| 2 | … consistent with @Digits#fraction() |
| 3 | the correct idiom when setting a new value is to normalized to the correct scale |