title: How to validate Spring MVC @PathVariable values?
body: <p>For a simple RESTful JSON api implemented in Spring MVC, can I use Bean Validation (JSR-303) to validate the path variables passed into the handler method?</p>
  
  <p>For example:</p>
  
  <pre><code> @RequestMapping(value = "/number/{customerNumber}")
   @ResponseBody
   public ResponseObject searchByNumber(@PathVariable("customerNumber") String customerNumber) {
   ...
   }
  </code></pre>
  
  <p>Here, I need to validate the customerNumber variables's length using Bean validation. Is this possible with Spring MVC v3.x.x? If not, what's the best approach for this type of validations?</p>
  
  <p>Thanks.</p>