@@ -556,14 +556,19 @@ export const validateParam = (param, isXml, isOAS3 = false) => {
556556 Only bother validating the parameter if the type was specified.
557557 */
558558 if ( type && ( required || value ) ) {
559- // These checks should evaluate to true if the parameter's value is valid
560- let stringCheck = type === "string" && value && ! validateString ( value )
559+ // These checks should evaluate to true if there is a parameter
560+ let stringCheck = type === "string" && value
561561 let arrayCheck = type === "array" && Array . isArray ( value ) && value . length
562562 let listCheck = type === "array" && Im . List . isList ( value ) && value . count ( )
563563 let fileCheck = type === "file" && value instanceof win . File
564- let booleanCheck = type === "boolean" && ! validateBoolean ( value )
565- let numberCheck = type === "number" && ! validateNumber ( value ) // validateNumber returns undefined if the value is a number
566- let integerCheck = type === "integer" && ! validateInteger ( value ) // validateInteger returns undefined if the value is an integer
564+ let booleanCheck = type === "boolean" && ( value || value === false )
565+ let numberCheck = type === "number" && value
566+ let integerCheck = type === "integer" && value
567+
568+ if ( required && ! ( stringCheck || arrayCheck || listCheck || fileCheck || booleanCheck || numberCheck || integerCheck ) ) {
569+ errors . push ( "Required field is not provided" )
570+ return errors
571+ }
567572
568573 if ( maxLength || maxLength === 0 ) {
569574 let err = validateMaxLength ( value , maxLength )
@@ -575,11 +580,6 @@ export const validateParam = (param, isXml, isOAS3 = false) => {
575580 if ( err ) errors . push ( err )
576581 }
577582
578- if ( required && ! ( stringCheck || arrayCheck || listCheck || fileCheck || booleanCheck || numberCheck || integerCheck ) ) {
579- errors . push ( "Required field is not provided" )
580- return errors
581- }
582-
583583 if ( maximum || maximum === 0 ) {
584584 let err = validateMaximum ( value , maximum )
585585 if ( err ) errors . push ( err )
0 commit comments