"use strict"; const errors = require("../errors"); const getValueType = require("../util/get-value-type"); module.exports = function createFunctionValidatorFunction(options = {}) { let guardedFunctionDescription = getValueType({ _isTypeRule: true, _baseType: "guardedFunction", _options: options }); // options.args // options.returnValue return function validateFunction(value) { if (typeof value === "function" && value._guardedFunction != null) { /* FIXME: Verify that the function signature matches. */ return true; } else { return new errors.ValidationError(`Expected ${guardedFunctionDescription}, got ${getValueType(value)} instead`); } }; };