settings/utils/mustContainProperties.js

12 lines
376 B
JavaScript
Raw Normal View History

2024-07-30 11:26:42 +00:00
const CustomError = require('../errors')
function mustContainProperties(req, requiredProperties) {
const missingProperties = requiredProperties.filter(prop => !req.body[prop])
if (missingProperties.length > 0) {
throw new CustomError.BadRequestError(`Missing properties: ${missingProperties.join(', ')}`)
}
}
module.exports = mustContainProperties