@@ -10,6 +10,7 @@ const {
1010 NumberMAX_SAFE_INTEGER,
1111 NumberMIN_SAFE_INTEGER,
1212 NumberParseInt,
13+ ObjectPrototypeHasOwnProperty,
1314 RegExpPrototypeExec,
1415 String,
1516 StringPrototypeToUpperCase,
@@ -150,6 +151,12 @@ function validateBoolean(value, name) {
150151 throw new ERR_INVALID_ARG_TYPE ( name , 'boolean' , value ) ;
151152}
152153
154+ function getOwnPropertyValueOrDefault ( options , key , defaultValue ) {
155+ return options == null || ! ObjectPrototypeHasOwnProperty ( options , key ) ?
156+ defaultValue :
157+ options [ key ] ;
158+ }
159+
153160/**
154161 * @param {unknown } value
155162 * @param {string } name
@@ -161,10 +168,9 @@ function validateBoolean(value, name) {
161168 */
162169const validateObject = hideStackFrames (
163170 ( value , name , options ) => {
164- const useDefaultOptions = options == null ;
165- const allowArray = useDefaultOptions ? false : options . allowArray ;
166- const allowFunction = useDefaultOptions ? false : options . allowFunction ;
167- const nullable = useDefaultOptions ? false : options . nullable ;
171+ const allowArray = getOwnPropertyValueOrDefault ( options , 'allowArray' , false ) ;
172+ const allowFunction = getOwnPropertyValueOrDefault ( options , 'allowFunction' , false ) ;
173+ const nullable = getOwnPropertyValueOrDefault ( options , 'nullable' , false ) ;
168174 if ( ( ! nullable && value === null ) ||
169175 ( ! allowArray && ArrayIsArray ( value ) ) ||
170176 ( typeof value !== 'object' && (
0 commit comments