diff --git a/lib/internal/validators.js b/lib/internal/validators.js index b3a7ee26554e1a..81329160f07323 100644 --- a/lib/internal/validators.js +++ b/lib/internal/validators.js @@ -140,12 +140,21 @@ function validateBoolean(value, name) { throw new ERR_INVALID_ARG_TYPE(name, 'boolean', value); } +/** + * @param {unknown} value + * @param {string} name + * @param {{ + * allowArray?: boolean, + * allowFunction?: boolean, + * nullable?: boolean + * }} [options] + */ const validateObject = hideStackFrames( - (value, name, { - nullable = false, - allowArray = false, - allowFunction = false, - } = {}) => { + (value, name, options) => { + const useDefaultOptions = options == null; + const allowArray = useDefaultOptions ? false : options.allowArray; + const allowFunction = useDefaultOptions ? false : options.allowFunction; + const nullable = useDefaultOptions ? false : options.nullable; if ((!nullable && value === null) || (!allowArray && ArrayIsArray(value)) || (typeof value !== 'object' && (