Annotation Type Valid


@Retention(SOURCE) @Target({METHOD,TYPE,PARAMETER}) public @interface Valid
Add @Valid annotation on a controller/method/BeanParam that we want bean validation to be included for. When we do this controller methods that take a request payload will then have the request bean (populated by JSON payload or form parameters) validated before it is passed to the controller method.

When trying to validate a @BeanParam bean, this will need to be placed on the BeanParam type.

When using this annotation we need to provide an implementation of Validator to use.

Alternatively we can use the Jakarta @Valid along with a Jakarta validator implementation.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Validation groups to use
  • Element Details

    • groups

      Class<?>[] groups
      Validation groups to use
      Default:
      {}