How to do conditional check express-validator 5.3.0? How to do conditional check express-validator 5.3.0? express express

How to do conditional check express-validator 5.3.0?


Conditional validation support is not present yet in express-validator v5.x.x, but it is coming soon.
Here's the Pull Request, in case you would like to give your feedback on the API: https://github.com/express-validator/express-validator/pull/658

However, please note that the legacy API (the one that uses req.checkBody(), req.getValidationResult(), etc, hasn't been removed from express-validator yet.

You can keep using it in v5.x.x just as you would in v3.x.x. It's just not recommended to do so, as it's deprecated and might be removed when v6 is due (not yet!).

All docs are here, side by side with the newer APIs docs.

Disclaimer: I'm an express-validator maintainer.