title: Is there a way to conditionally skip validating bean fields?
body: <p>We have the situation where we have a Customer and Address domain class like:</p>
  
  <p>Customer:</p>
  
  <pre><code>@NotNull
  private Long id;
  
  @NotBlank
  @Length(max = 100)
  private String name;
  
  @NotNull
  @Valid
  private Address homeAddress;
  
  @Valid
  private Address deliveryAddress;
  </code></pre>
  
  <p>Address:</p>
  
  <pre><code>@NotBlank
  @Length(max = 100)
  private String streetname;
  
  @NotBlank
  @Length(max = 10)
  private String housenumber;
  
  @Length(max = 10)
  private String housenumberExtension;
  
  @NotBlank
  @Pattern(regexp = "[0-9]{4}[A-Z]{2}")
  private String postcode;
  
  @NotBlank
  @Length(max = 100)
  private String city;
  </code></pre>
  
  <p>It uses the @Valid annotation to validate the whole Customer graph including the child Address fields.</p>
  
  <p>We have the case where we only want to validate the Address fields in case it has non empty fields.
  So e.g. in case all customer.homeAddress fields are null it should be ok and should not result in validation errors.</p>
  
  <p>I know it would be better then to make homeAddress null to skip validation.
  But we are using an old domain model where this is not the case (and we cannot change it). Anyway we are trying to incorporate java.validation annotations.</p>
  
  <p>I wonder if we could apply a (custom) annotation on class level which can force the validation api to skip that bean?</p>