Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validate = context => {
const { service, method, path } = context;
const parameters = service.methods[method];
if (parameters.includes('id') && context.id === undefined) {
throw new Error(`An id must be provided to the '${path}.${method}' method`);
}
if (parameters.includes('data') && !_.isObjectOrArray(context.data)) {
throw new Error(`A data object must be provided to the '${path}.${method}' method`);
}
return context;
};