title: Spring Boot Validate JSON Mapped via ObjectMapper GET @RequestParam
body: <p>What's the simplest approach to validating a complex JSON object being passed into a GET REST contoller in spring boot that I am mapping with <em>com.fasterxml.jackson.databind.ObjectMapper</em>?</p>
  
  <p>Here is the controller:</p>
  
  <pre><code>@RestController
  @RequestMapping("/products")
  public class ProductsController {
  
  @GetMapping
  public ProductResponse getProducts(
          @RequestParam(value = "params") String requestItem
  ) throws IOException {
      final ProductRequest productRequest =
              new ObjectMapper()
                      .readValue(requestItem, ProductRequest.class);
  
      return productRetriever.getProductEarliestAvailabilities(productRequest);
  }}
  </code></pre>
  
  <p>DTO request object I want to validate:</p>
  
  <pre><code>public class ProductRequest {
  private String productId;
  
  public String getProductId() {
      return productId;
  }
  
  public void setProductId(String productId) {
      this.productId = productId;
  }}
  </code></pre>
  
  <p>I was thinking of using annotations on the request DTO however when I do so, they are not triggering any type of exceptions, i.e. <em>@NotNull</em>. I've tried various combinations of using <em>@Validated</em> at the controller as well as <em>@Valid</em> in the <em>@RequestParam</em> and nothing is causing the validations to trigger.</p>