fix: array constraint validation only if value was provided (#7112)

This commit is contained in:
Mahtis Michel
2021-03-30 21:33:56 +02:00
committed by GitHub
parent cabba625c2
commit 4103e0f919
2 changed files with 35 additions and 1 deletions

View File

@@ -772,6 +772,39 @@ describe("utils", () => {
value = []
assertValidateParam(param, value, [])
// valid, empty array, with validation constraint
param = {
required: false,
schema: {
type: "array",
minItems: 1
}
}
value = undefined
assertValidateOas3Param(param, value, [])
// invalid, empty array, with minItems validation constraint
param = {
required: false,
schema: {
type: "array",
minItems: 2
}
}
value = ["12"]
assertValidateOas3Param(param, value, ["Array must contain at least 2 items"])
// valid, valid array with satisfied minItems validation constraint
param = {
required: false,
schema: {
type: "array",
minItems: 1
}
}
value = ["probe"]
assertValidateOas3Param(param, value, [])
// invalid, items do not match correct type
param = {
required: false,