valid-props
Version:
Validates an objects properties
16 lines (13 loc) • 413 B
JavaScript
;
function verifyPropertiesExist(params, schema) {
var missingProperties = Object.keys(schema).filter(function (key) {
return !params.hasOwnProperty([key]);
});
if (missingProperties.length) {
var errorMsg = 'Missing properties: ' + missingProperties.join(', ');
throw new Error(errorMsg);
}
}
module.exports = {
propertiesExist: verifyPropertiesExist
};