title: How to do conditional check express-validator 5.3.0?
body: <pre><code>export function valUPM() {
    return (req: Request, _res: Response, next: NextFunction) =&gt; {
      req
        .checkBody(
          "paymentType",
          `paymentType: ${messages.getFromSession(req, "mustNotBeEmpty")}`
        )
        .notEmpty();
      if (req.body.paymentType === "USP") {
        req
          .checkBody(
            "storeId",
            `storeId: ${messages.getFromSession(req, "mustNotBeEmpty")}`
          )
          .notEmpty();
      } else if (req.body.paymentType === "CC") {
        if (req.body.register) {
          req
            .checkBody(
              "register",
              `register: ${messages.getFromSession(req, "mustBeBoolean")}`
            )
            .isBoolean();
        } else {
          req
            .checkBody(
              "register",
              `register: ${messages.getFromSession(req, "mustNotBeEmpty")}`
            )
            .notEmpty();
        }
      }
      req.getValidationResult().then(errs =&gt; {
        if (errs.isEmpty()) {
          return next();
        }
        const error = new BFFError(
          400,
          "BadRequest",
          1,
          errs.array().map(error =&gt; {
            return { [error.param]: error.msg };
          })
        );
        return next(Error(JSON.stringify(error)));
      });
    };
  }
  </code></pre>
  
  <p>After the change to API how to implement this type of logic in express validators </p>
  
  <p>Calling req.checkBody or the required validation function inside an if loop did the trick like shown above but after change in API how can this be implemented 
  I tried a work around of checking the paymentTYpe as a custom validator and implementing the checks and throwing the message inside the custom validator but the keys change .</p>
  
  <p>Using the current APi what is the proper way to do this as this will be useful for all the people who would want to update from 3.0.0s to latest express-validator API</p>