What is the purpose of the @Valid annotation in Spring Boot when used in controller methods?

  • It disables validation.
  • It defines a new validation rule.
  • It validates incoming request data.
  • It initializes the Spring Boot application.
When the @Valid annotation is used in Spring Boot controller methods, it serves the purpose of validating incoming request data. This annotation is typically applied to method parameters, such as a @RequestBody, to trigger validation of the request body based on the validation rules defined for the associated class. It ensures that incoming data is valid according to the specified constraints. The other options are not the correct purposes of the @Valid annotation.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *