'javax.validation.constraints to validate fraction number of digits of float variable

I would like to validate a float number so that it would be in the format: XXX.XX. Which javax validation constraint could be used? Digits doesn't seem to support float data type

@field:NotNull
@field:Digits(fraction = 2, integer = 3)
var enrollmentPercentage: Float? = null


Solution 1:[1]

Have you already noticed the @BigDecimal Annotation? https://www.baeldung.com/javax-bigdecimal-validation Also there's the posibility to use Annotations directly without field: as prefix. You may want to try this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fl0r3