title: Is it possible to validate an object field only if it is not null?
body: <p>There are two existing variants of this question:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/19262979/validate-only-if-the-field-is-not-null">Validate only if the field is not Null</a> : A solution to a conditionally handling a <code>String</code> field </li>
  <li><a href="https://stackoverflow.com/questions/17570314/hibernate-validation-only-validate-if-object-is-not-null">Hibernate validation - only validate if object is not null</a> : The only answer demonstrates the behavior and hints at how you could handle it when triggering the validation manually.</li>
  </ol>
  
  <p>My question adds the qualifier of how can I do this when using @Valid on an object which may be null. </p>
  
  <p>The use case here is that we have two fields where one or the other need to be not null (Custom validator on the class that contains the fields). When one is not null, I need it to be valid. Do I then need to fully and manually validate that object within my custom validator, adding more responsibility to it than it was intended for?</p>
  
  <p>Using only annotations in this case causes a NullPointerException to be thrown, which breaks it out of validation before it could be handled. Is there not currently a way to do this?</p>