I am trying to validate the limit parameter in the following method, but there is not any error or warning message even I enter 0 (when I enter -2, an unknown error message returned.
@RestController
@Validated // I also add this
@RequestMapping("/api/v1")
public class EmployeeController {
@GetMapping("/employees/{limit}")
public ResponseEntity<ApiResponse<List<Employee>>> findTopNEmployeeBySalary(
@PathVariable("limit") @Valid @Min(1) int limit) {
// ...
}
}
So, what I am missing in here?