title: Spring Validation - How to retrieve errors.rejectValue in my Contoller?
body: <p>I have my validate method in my TestValidator as follows</p>
  
  <pre><code>@Override
  public void validate(Object target, Errors errors) {
      Test test = (Test) target;
      String testTitle = test.getTestTitle();
  
      //**ErrorCheck1** - This works, and I am able to pull the value in my controller
      ValidationUtils.rejectIfEmptyOrWhitespace(errors, "testTitle", "test.testTitle.projec", "My msg");
  
  
      if (testTitle != null &amp;&amp; testTitle.length() &lt; 4) {
          logger.error("Inside custom validation"+test.testTitle().length());
  
          //**Error Check2**
          //***HOW DO I RETRIEVE THE BELOW VALUE in My controller
          errors.rejectValue(testTitle, "test.testTitle.lessThen4");
          errors.addAllErrors(errors);
          logger.error("Entered If condition of validate");
      }
  }
  </code></pre>
  
  <p>And my controller is </p>
  
  <pre><code>@RequestMapping(value = "/test", method = RequestMethod.PUT)
  public ResponseEntity&lt;BasicResponseDTO&gt; newTest(@Valid  @RequestBody Test test, BindingResult result) {
  
      if (result.hasErrors()){
          logger.error("Entered Errors");
          BasicResponseDTO basicResponseDTO = new BasicResponseDTO();
          basicResponseDTO.setCode(ResponseCode.BAD_REQUEST);
          return new ResponseEntity&lt;BasicResponseDTO&gt;(basicResponseDTO, HttpStatus.BAD_REQUEST);
      }
  }
  </code></pre>
  
  <p>When my ErrorCheck1 condition is activated, my IF condition inside the controller is able to retrieve it.
  However, in my ErrorCheck2, because of of the errors.rejectValue I immediately get an error on the console and am not able to gracefully handle the situation when the testTitle length is less than 4.</p>
  
  <blockquote>
    <p>What is the alternative to errors.rejectValue so that I may handle the
    error in my controller ?</p>
  </blockquote>