You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
379 B
JavaScript

'use strict';
module.exports = function requireProperties(object, properties) {
let missingProperties = [];
properties.forEach((property) => {
if (object[property] == null) {
missingProperties.push(property);
}
});
if (missingProperties.length > 0) {
throw new Error(`Missing required properties: ${missingProperties.join(", ")}`);
} else {
return true;
}
};