module.exports = (schema) => (req, _res, next) => { try { req.validated = schema.parse({ body: req.body, params: req.params, query: req.query }); req.body = req.validated.body; next(); } catch (error) { next(error); } };