diff --git a/src/core/utils.js b/src/core/utils.js index 4595c798..8babdbd8 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -494,8 +494,8 @@ export const validateParam = (param, isXml, isOAS3 = false) => { let listCheck = type === "array" && Im.List.isList(value) && value.count() let fileCheck = type === "file" && value instanceof win.File let booleanCheck = type === "boolean" && (value || value === false) - let numberCheck = type === "number" && value - let integerCheck = type === "integer" && value + let numberCheck = type === "number" && (value || value === 0) + let integerCheck = type === "integer" && (value || value === 0) if ( required && !(stringCheck || arrayCheck || listCheck || fileCheck || booleanCheck || numberCheck || integerCheck) ) { errors.push("Required field is not provided") diff --git a/test/core/utils.js b/test/core/utils.js index 918d8431..73861845 100644 --- a/test/core/utils.js +++ b/test/core/utils.js @@ -700,6 +700,14 @@ describe("utils", function() { } assertValidateParam(param, ["Required field is not provided"]) + // valid integer, but 0 is falsy in JS + param = { + required: true, + type: "integer", + value: 0 + } + assertValidateParam(param, []) + // valid integer param = { required: true,