create todo list

This commit is contained in:
Primakov Alexandr Alexandrovich
2025-01-18 16:50:58 +03:00
parent d88e680413
commit fb644b6f7b
8 changed files with 102 additions and 69 deletions

View File

@@ -0,0 +1,19 @@
const requiredValidate =
(...fields) =>
(req, res, next) => {
const errors = []
fields.forEach((field) => {
if (!req.body[field]) {
errors.push(field);
}
})
if (errors.length) {
throw new Error(`Не все поля заполнены: ${errors.join(", ")}`);
} else {
next()
}
}
module.exports.requiredValidate = requiredValidate;