"use strict"; const wrapError = require("@validatem/wrap-error"); const isPlainObject = require("@validatem/is-plain-object"); const ValidationError = require("@validatem/error"); module.exports = function (operations) { return function isObjectType(expectedType) { // FIXME: Why not using allowExtraProperties + object syntax here? // FIXME: Add AST node check return wrapError(`Must be a query object of type '${expectedType}'`, [ isPlainObject, function (value) { if (value.type !== expectedType) { // FIXME: Maybe figure out a better user-facing name for the concept of a 'query object' (query segment)? throw new ValidationError(`Must be of type '${expectedType}'`); } } ]); }; };