function assertObject(attr, data) {
  if (data === null || data === undefined) {
    return null;
  }

  if (typeof data !== "object" || Array.isArray(data)) {
    throw new BadRequestError(`Attribute ${attr} must be of type "object"`);
  }

  return data;
}
Throws if the provided data is not an object.
Returns the unmodified data if validated

@throws
@param {string} attr - tested attribute name
@param {*} data
@return {object}