app.post('/api/customers', [ body('name').notEmpty().withMessage('Name is required').isString().withMessage('Name must be a string'), ], (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(422).json(errors); }
app.put('/api/customers/:id', [ body('name').notEmpty().withMessage('Name is required').isString().withMessage('Name must be a string'), ], (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(422).json(errors); }