Is there a way to validate primitive (int, String etc.) GET parameters using annotations?
@RequestMapping(value = "/api/{someInt}",
method = RequestMethod.GET,
produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> someRestApiMethod(
@PathVariable
@Valid @Min(0) @Digits(integer=10, fraction=0)
int someInt) {
//...
return new ResponseEntity<String>("sample:"+someInt, HttpStatus.OK);
}
As you see I have put a bunch of annotations to validate someInt to be a positive integer with 10 digits but still it accepts every kind of integers.