lately I was trying to understand how spring processes @Valid annotation. For example look at the following controller's method:
@RequestMapping(value = "/create", method = RequestMethod.POST)
public ModelAndView createEmployee(@Valid EmployeeForm form, Errors errors) {
if(errors.hasErrors()) {
//validation errors
}
//method code
}
I am struggling to understand how errors
instance is getting populated with validation errors in real-time. Does Spring, during compilation of the controller, inject code responsible for validation at the beginning of the createEmployee method? If so how this code would look?
I really tried to find an example of how this validation is performed in real life but it's just impossible. Help me please.