How to use the @feathersjs/commons._.isObjectOrArray function in @feathersjs/commons

To help you get started, we’ve selected a few @feathersjs/commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathersjs / feathers / packages / feathers / lib / hooks / base.js View on Github external
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;
};