Skip to main content

@Valid

Learn @Valid (Validation, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes @Valid ( jakarta.validation.Valid ) tells Spring to run Bean Validation on a method argument, such as a form object or a @RequestBody . Failure : with @RequestBody it throws MethodArgumentNotValidException (400); with @ModelAttribute and a following BindingResult you handle errors yourself. Cascade : placed on a field, it validates the nested object or the elements of a collection too.

More lessons in Validation