multy-stub/server/routers/old/stc-22-24/midlewares/checkRequired.midleware.js
Primakov Alexandr Alexandrovich 4b0d9b4dbc mongoose + tests
2024-10-16 11:06:23 +03:00

13 lines
353 B
JavaScript

const checkRequiredMidleware = (options) => (req, res, next) => {
// eslint-disable-next-line no-restricted-syntax
for (const option of options) {
if (!req.body[option]) {
res.status(400).send(`Required field ${option} is not present`)
return
}
}
next()
}
module.exports = checkRequiredMidleware