I am using Hibernate Validator in addition to javax.validation
library to validate request bodies of controllers in a Spring MVC application. There are annotations for constraints that help with min and max boundaries and also with the number of digits but I couldn't find a way to accept only specific numbers. For example what if I only want to accept values 10, 20 and 50?
I'm aware that it's possible to use org.springframework.validation.Validator
interface to create more complex rules. Another thing that came to mind is to create an enum with desired numeric values but it doesn't seem like a clean solution. I'm curious to know if there is a better, simpler way to achieve what I want.