99 NumberMAX_SAFE_INTEGER,
1010 NumberMIN_SAFE_INTEGER,
1111 NumberParseInt,
12+ ObjectPrototypeHasOwnProperty,
1213 RegExpPrototypeExec,
1314 String,
1415 StringPrototypeToUpperCase,
@@ -135,6 +136,12 @@ function validateBoolean(value, name) {
135136 throw new ERR_INVALID_ARG_TYPE ( name , 'boolean' , value ) ;
136137}
137138
139+ function getOwnPropertyValueOrDefault ( options , key , defaultValue ) {
140+ return options == null || ! ObjectPrototypeHasOwnProperty ( options , key ) ?
141+ defaultValue :
142+ options [ key ] ;
143+ }
144+
138145/**
139146 * @param {unknown } value
140147 * @param {string } name
@@ -146,10 +153,9 @@ function validateBoolean(value, name) {
146153 */
147154const validateObject = hideStackFrames (
148155 ( value , name , options ) => {
149- const useDefaultOptions = options == null ;
150- const allowArray = useDefaultOptions ? false : options . allowArray ;
151- const allowFunction = useDefaultOptions ? false : options . allowFunction ;
152- const nullable = useDefaultOptions ? false : options . nullable ;
156+ const allowArray = getOwnPropertyValueOrDefault ( options , 'allowArray' , false ) ;
157+ const allowFunction = getOwnPropertyValueOrDefault ( options , 'allowFunction' , false ) ;
158+ const nullable = getOwnPropertyValueOrDefault ( options , 'nullable' , false ) ;
153159 if ( ( ! nullable && value === null ) ||
154160 ( ! allowArray && ArrayIsArray ( value ) ) ||
155161 ( typeof value !== 'object' && (
0 commit comments