title: Spring boot post request model validation
body: <p>What is recommended/best way to validate the post request DTO bean ?
  If validation failed I need to send customized error message like</p>
  
  <pre><code>{
  "code": "invalid_fields",
  "fields": {
      "email": "Required",
      "password": "Required",
    }
  }
  </code></pre>
  
  <p>DTO model</p>
  
  <pre><code>public class SignUpRequest {
  
      @JsonProperty("email")
      String email;
  
      @JsonProperty("password")
      String password;
  
     public Result validate(){
  
     }
  
  }
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>@PostMapping(value = "/register")
  public ResponseEntity&lt;Object&gt; signupRider(@RequestBody SignUpRequest signUpRequest) {
          Result result = signUpRequest.validate();
  
          return new ResponseEntity&lt;&gt;(x, HttpStatus.OK);
  }
  </code></pre>
  
  <p><strong>SignUpRequest DTO has the method validate.</strong>
  What is the spring way of doing the validation ?</p>
  
  <p>Thanks.</p>