@@ -126,7 +126,8 @@ const {
126126 validateNumber,
127127 validateString,
128128 validateUint32,
129- validateAbortSignal
129+ validateAbortSignal,
130+ validateBoolean,
130131} = require ( 'internal/validators' ) ;
131132const fsPromisesInternal = require ( 'internal/fs/promises' ) ;
132133const { utcDate } = require ( 'internal/http' ) ;
@@ -761,27 +762,27 @@ function requestOnConnect(headers, options) {
761762const setAndValidatePriorityOptions = hideStackFrames ( ( options ) => {
762763 if ( options . weight === undefined ) {
763764 options . weight = NGHTTP2_DEFAULT_WEIGHT ;
764- } else if ( typeof options . weight !== 'number' ) {
765- throw new ERR_INVALID_ARG_VALUE ( 'options.weight' , options . weight ) ;
766- }
765+ }
766+
767+ validateNumber ( options . weight , 'options.weight' ) ;
767768
768769 if ( options . parent === undefined ) {
769770 options . parent = 0 ;
770- } else if ( typeof options . parent !== 'number' || options . parent < 0 ) {
771- throw new ERR_INVALID_ARG_VALUE ( 'options.parent' , options . parent ) ;
772- }
771+ }
772+
773+ validateNumber ( options . parent , 'options.parent' , 0 ) ;
773774
774775 if ( options . exclusive === undefined ) {
775776 options . exclusive = false ;
776- } else if ( typeof options . exclusive !== 'boolean' ) {
777- throw new ERR_INVALID_ARG_VALUE ( 'options.exclusive' , options . exclusive ) ;
778777 }
779778
779+ validateBoolean ( options . exclusive , 'options.exclusive' ) ;
780+
780781 if ( options . silent === undefined ) {
781782 options . silent = false ;
782- } else if ( typeof options . silent !== 'boolean' ) {
783- throw new ERR_INVALID_ARG_VALUE ( 'options.silent' , options . silent ) ;
784783 }
784+
785+ validateBoolean ( options . silent , 'options.silent' ) ;
785786} ) ;
786787
787788// When an error occurs internally at the binding level, immediately
@@ -1784,10 +1785,11 @@ class ClientHttp2Session extends Http2Session {
17841785 // stream by default if the user has not specifically indicated a
17851786 // preference.
17861787 options . endStream = isPayloadMeaningless ( headers [ HTTP2_HEADER_METHOD ] ) ;
1787- } else if ( typeof options . endStream !== 'boolean' ) {
1788- throw new ERR_INVALID_ARG_VALUE ( 'options.endStream' , options . endStream ) ;
17891788 }
17901789
1790+ validateBoolean ( options . endStream , 'options.endStream' ) ;
1791+
1792+
17911793 const headersList = mapToHeaders ( headers ) ;
17921794
17931795 const stream = new ClientHttp2Stream ( this , undefined , undefined , { } ) ;
0 commit comments