Relative Content

Tag Archive for node.jsvalidationexpress-validator

Express-Validator: how to stop validation after checking for mandatory parameters?

I am using Express-Validator to validate some query parameters to a RESTful API written in node.js. I would like to “bail()” after running the mandatory checks so that there will be a message for each of the missing params, but not for subsequent checks on their values. Here are some sample errors demonstrating the issue. You can see that the missing fields are reported, but then there is also an error about the ticker symbol format (which I don’t want to mix with messages about missing params):