title: Yup how to validate mandatory fields on null object
body: <p>I have a problem regarding the validation of mandatory fields which are properties of a (possibly) null object.</p>
  
  <p>Here is an example schema : </p>
  
  <pre><code>object().shape({
     catalog: {
        brand: string().required()
     }
  })
  </code></pre>
  
  <p>If I try to validate the following object against this schema, I get the expected error : brand is required. From what I understood, there is a default value created for undefined object which mimics the shape of the object in the schema. This is the behavior I expected and what I want.</p>
  
  <pre><code>{ catalog: undefined }
  
  // "catalog.brand is a required field"
  </code></pre>
  
  <p>But in my case, I don't receive an object with undefined, but with null. And I can't figure out how to manage the same result with a null value.</p>
  
  <pre><code>{ catalog: null }
  
  // No error on catalog.brand
  </code></pre>
  
  <p>Manually casting null to undefined is out of the question as there is a good reason why I receive null.</p>
  
  <p>Here is a codesandbox which reproduces my use case : </p>
  
  <p><a href="https://codesandbox.io/s/yup-playground-tbfcj" rel="nofollow noreferrer">https://codesandbox.io/s/yup-playground-tbfcj</a></p>
  
  <p>I would really appreciate a bit of help on this, thanks :)</p>