title: Annotation for Mandatory attribute in json validation in spring rest controller
body: <p>I have a spring rest service which accepts the Person object. Person object has a name, phone number, and email. While adding a person, the phone number is mandatory. If the phone number attribute is present, it validates for null or empties using <code>@NotNull</code> or <code>@NotBlank</code> or <code>@NotEmpty</code>. But if the attribute doesn't exist, the validation is not working. Please suggest any validation annotation present to check the attribute exists in JSON request.</p>
  
  <p>following is the request body test cases</p>
  
  <blockquote>
    <p>{"name":"anu", "phoneNumber": "","email" :"test@gmail.com" } //
    Validation works</p>
    
    <p>{"name":"anu", "phoneNumber": null,"email" :"test@gmail.com" } //
    Validation works</p>
    
    <p>{"name":"anu","email" :"test@gmail.com" } // Validation doesnt works',
    Required help to find the annotation.</p>
  </blockquote>
  
  <pre><code>class Person {
   @NotNull
  private String name;
    @NotNull(message = "email.empty") 
     @Email(regexp = EMAIL_PATTERN, message = "email.invalid")
  private String email;
   @NotNull(message = "phonenumber.empty")
     @Pattern(regexp = PHONE_NUMBER_PATTERN, message = "phonenumber.invalid")
  private String phoneNumber;
  ...
  }
  </code></pre>
  
  <p>Please find my controler</p>
  
  <pre><code>@RequestMapping(value = "/createAdminPerson", method = POST, consumes = BusinessPersonConstants.MEDIA_TYPE, produces = "application/json;charset=UTF-8")
      public ResponseEntity&lt;Boolean&gt; createAdminPerson(
              @Validated @RequestBody Person createAdminPerson) {
  ...
  }
  </code></pre>
  
  <p>I tried @NotNull, @Notempty, @NotBlank. Please help</p>