Tried to add @Max validation for the sizes request parameter. However, it seems whatever value I put in will be valid.
A simple controller method in a spring boot application.
@GetMapping("/all")
public String getAll(@RequestParam @Max(value=20, message = "should be less than 20") int sizes) {
if (sizes > 20) {
return "Pass but not valid";
}
return "Valid";
}
when request param sizes is 21, I get Pass but not valid rather error message http://localhost:8080/all?sizes=21
Any advice? Thanks