I have a minor unit setup for amounts, which is: 0.01
It means the amounts are allowed to have maximum 2 decimals.
What could be the best and easiest validation check in Java for these examples:
- 5 --> valid
- 5.0 --> valid
- 5.00 --> valid
- 5.000 --> valid
- 5.1 --> valid
- 5.11 --> valid
- 5.111 --> NOT valid
- 5.110 --> valid
Code should be something like:
public void isValid(BigDecimal amountToCheck, BigDecimal minorUnit) {
//TODO
}