title: Is it possible to validate @RequestParam in Spring MVC REST endpoint?
body: <p>In Jersey 2 it is possible to do this:</p>
  
  <pre><code>@GET
  @PATH("user/{email}")
  public IDto getUser(@NotNull @Email @PathParam("email") String validEmail) {
      return userManagementService.findUserByEmail(validEmail);
  }
  </code></pre>
  
  <p>But I cannot make something similar to work in Spring MVC, it seems that the validation is only done when providing an object in @RequestBody or using an SpringMVC Form, for example the following won't work:</p>
  
  <pre><code>@RequestMapping(value="/user/{email}", method = RequestMethod.GET)
  public @ResponseBody IDto getUser(@NotNull @Email @PathVariable String validEmail) {
      return userManagementService.findUserByEmail(validEmail);
  }   
  </code></pre>
  
  <p>There are other similar questions, but those seem to be oriented to Spring MVC UI applications, in my case it is only a REST API which returns JSON response so I don't have any View to map/bind to the controller.</p>