@@ -37,6 +37,7 @@ const {
3737const { once } = require ( 'internal/util' ) ;
3838const { toPathIfFileURL } = require ( 'internal/url' ) ;
3939const {
40+ validateBoolean,
4041 validateInt32,
4142 validateUint32
4243} = require ( 'internal/validators' ) ;
@@ -674,15 +675,11 @@ const defaultRmdirOptions = {
674675const validateRmOptions = hideStackFrames ( ( path , options , callback ) => {
675676 try {
676677 options = validateRmdirOptions ( options , defaultRmOptions ) ;
678+ validateBoolean ( options . force , 'force' ) ;
677679 } catch ( err ) {
678680 return callback ( err ) ;
679681 }
680682
681- if ( typeof options . force !== 'boolean' )
682- return callback (
683- new ERR_INVALID_ARG_TYPE ( 'force' , 'boolean' , options . force )
684- ) ;
685-
686683 lazyLoadFs ( ) . stat ( path , ( err , stats ) => {
687684 if ( err ) {
688685 if ( options . force && err . code === 'ENOENT' ) {
@@ -706,9 +703,7 @@ const validateRmOptions = hideStackFrames((path, options, callback) => {
706703
707704const validateRmOptionsSync = hideStackFrames ( ( path , options ) => {
708705 options = validateRmdirOptions ( options , defaultRmOptions ) ;
709-
710- if ( typeof options . force !== 'boolean' )
711- throw new ERR_INVALID_ARG_TYPE ( 'force' , 'boolean' , options . force ) ;
706+ validateBoolean ( options . force , 'force' ) ;
712707
713708 try {
714709 const stats = lazyLoadFs ( ) . statSync ( path ) ;
@@ -742,9 +737,7 @@ const validateRmdirOptions = hideStackFrames(
742737
743738 options = { ...defaults , ...options } ;
744739
745- if ( typeof options . recursive !== 'boolean' )
746- throw new ERR_INVALID_ARG_TYPE ( 'recursive' , 'boolean' , options . recursive ) ;
747-
740+ validateBoolean ( options . recursive , 'recursive' ) ;
748741 validateInt32 ( options . retryDelay , 'retryDelay' , 0 ) ;
749742 validateUint32 ( options . maxRetries , 'maxRetries' ) ;
750743
0 commit comments