title: Conditionally run check in express-validator
body: <p>I am trying to conditionally run check in express validator, the functional part of the validator can easily be handled because I am passing in req but the check part won't conditionally run. Please help</p>
  
  <p>I've tried turning the check part to a function and it is not working. This is what I want to achieve but the tenary fails </p>
  
  <pre><code>const onewayCheck = body('tripType').equals('one-way') ? [
    body('currentOfficeLocation')
      .exists({ checkFalsy: true })
      .withMessage('currentOfficeLocation Current Office Location is required')
      .isInt()
      .withMessage('currentOfficeLocation Current Office Location must be an integer'),
    body('destination')
      .exists({ checkFalsy: true })
      .withMessage('destination Destination is required')
      .isInt()
      .withMessage('destination Destination must be an integer'),
    body('departureDate')
      .exists({ checkFalsy: true })
      .withMessage('departureDate Departure date is required'),
    body('travelreasons')
      .exists({ checkFalsy: true })
      .withMessage('travelReasons Travel Reasons is required')
      .isString()
      .withMessage('travelReasons Travel Reasons should be strings'),
    body('accommodation')
      .exists({ checkFalsy: true })
      .withMessage('accommodation Accommodation is required')
      .isInt()
      .withMessage('accommodation Accommodation must be an integer'),
  ] : [];
  </code></pre>
  
  <p>I want to ensure the check woks</p>