I have the following Rest Controller in Java/Spring. The validation of constraints are checked. However, these are completed before it reaches the body of my 'bar' method. How can I handle a violation case? Can I customize the 400 response bodies?
@RestController
@RequestMapping("foo")
public class FooController {
@RequestMapping(value = "bar", method = RequestMethod.POST)
public ResponseEntity<Void> bar(@RequestBody @Valid Foo foo) {
//body part
return ResponseEntity.status(HttpStatus.OK).build();
}
}