[Solved] Are Express Validator and Express Mutually Exclusive or Dependent Packages [closed]


Since v4.16.0 you no longer need to use body-parser, instead you can use express.json(). Once you have the request body you can use express-validator to validate the input.

Code examples available here

Edit

To access the request body you have two options:

app.use(bodyParser.json()) // Option A: middleware bodyParser
app.use(express.json()) // Option B: in-built method

Neither of these options provide validation of the body, only access to it. To validate a request body you must add middleware such as express-validator

app.use(expressValidator())

4

solved Are Express Validator and Express Mutually Exclusive or Dependent Packages [closed]