title: Express Validator - How to handle conditional Validation
body: <p>I have a form where if a person's shipping address is different from their Billing address they will select a radio button saying "no".</p>
  
  <p>I need to be able to check what the value of this is, and if it is "no" check the form that unfolds. if it is "yes" I skip on to the next validations below. The "yes section is working, but the "no" section always returns invalidated. is there a way to nest validations in a conditional like this with this library?</p>
  
  <p>Here is a screenshot of the form: </p>
  
  <p><a href="https://i.stack.imgur.com/1qpQ4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1qpQ4.png" alt="Test Form Image"></a></p>
  
  <p>Here is the validation code i have for this scenario: </p>
  
  <pre><code>    router.post('/testData2/', [
        body('billingSameAsShipping', "Please Fill All Fields Of Your Billing Address").custom((value) =&gt; {
          if (value === 'no') {
            [
              body('billingFirstName', "Please Enter Your First Name").isLength({
                min: 1
              }),
              body('billingLastName', "Please Enter Your Last Name").isLength({
                min: 1
              }),
              body('billingAddress1', "Please Enter Your Billing Address").isLength({
                min: 1
              }),
              body('billingZip', "Please Enter Your Billing ZipCode").isLength({
                min: 1
              }),
              body('billingCity', "Please Enter Your Billing City").isLength({
                min: 1
              }),
              body('billingState', "Please Enter Your Billing State").isLength({
                min: 1
              })
            ]
          } else {
  
            return Promise.resolve();
          }
  
        }),
      body('creditCardNumber', 'Please Enter A Vaild Credit Card Number').isCreditCard(),
      body('expmonth', 'Exp Month Empty').isLength({
        min: 1
      }),
      body('expyear', 'Exp Year Empty').isLength({
        min: 1
      }),
      body('CVV', 'CVV Empty').isLength({
        min: 3
      })
    ],
    (req, res) =&gt; {...
  </code></pre>
  
  <p>Here is the request object we are checking against</p>
  
  <pre><code>{
    billingSameAsShipping: 'no',
    billingFirstName: 'First',
    billingLastName: 'Last',
    billingAddress1: '450 Test Ave',
    billingZip: '12345',
    billingCity: 'San Diego',
    billingState: 'CA',
  }
  </code></pre>