Note: I read almost all stack post that i get when i search @valid vs @validated and could not find answer so i am posting this.
I am so confused what @Validated is doing here. If inputParms is not valid, it is throwing javax.validation.ConstraintViolationException and not even going inside code. But if I replace @Validated with @Valid No exception thrown and bindingResult.hasErrors() is catching it.
@RestController
@Validated // what is this doing ??
public class MyRestController{
@PostMapping(value="/my-data",produces= {MediaType.APPLICATION_JSON_UTF8_VALUE})
public ResponseEntity<?> doSomething(@Valid @RequestBody MyInputParam inputParms,BindingResult bindingResult){
if(bindingResult.hasErrors()) {
//do something here
}
}
}
So if i use @Validated, BindingResult is not useful at all ?
Or even simply how @Validated is different from @Valid