@@ -10,6 +10,7 @@ const {
10
10
NumberMAX_SAFE_INTEGER,
11
11
NumberMIN_SAFE_INTEGER,
12
12
NumberParseInt,
13
+ ObjectPrototypeHasOwnProperty,
13
14
RegExpPrototypeExec,
14
15
String,
15
16
StringPrototypeToUpperCase,
@@ -150,6 +151,12 @@ function validateBoolean(value, name) {
150
151
throw new ERR_INVALID_ARG_TYPE ( name , 'boolean' , value ) ;
151
152
}
152
153
154
+ function getOwnPropertyValueOrDefault ( options , key , defaultValue ) {
155
+ return options == null || ! ObjectPrototypeHasOwnProperty ( options , key ) ?
156
+ defaultValue :
157
+ options [ key ] ;
158
+ }
159
+
153
160
/**
154
161
* @param {unknown } value
155
162
* @param {string } name
@@ -161,10 +168,9 @@ function validateBoolean(value, name) {
161
168
*/
162
169
const validateObject = hideStackFrames (
163
170
( 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 ) ;
168
174
if ( ( ! nullable && value === null ) ||
169
175
( ! allowArray && ArrayIsArray ( value ) ) ||
170
176
( typeof value !== 'object' && (
0 commit comments