我有一个以下 JSON 模式,我正在尝试使用 JSON 模式验证器进行验证
JSON 架构:
{
"$schema": "http://json-schema.org/draft-07schema#",
"description": "Create Orders Schema",
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"country": {
"default": "United States of America",
"enum": ["United States of America", "Canada"]
}
},
"if": {
"properties": { "country": { "const": "United States of America" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[0-9]{5}(-[0-9]{4})?" } }
},
"else": {
"properties": { "postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" } }
}
}
当我传递国家“加拿大”的错误邮政编码模式时,它不会验证并且会通过。
有效负载无效:
{
"street_address": "24 Sussex Drive",
"country": "Canada",
"postal_code": "10000"
}
我是否遗漏了什么或者 JSON 验证器不支持条件 if-then-else?
提前致谢
问题可能是架构使用了 Draft 7 JSON Schema 规范。连接器的文档指出,验证架构操作仅支持草稿 3 或 4:
此连接器仅支持 JSON 架构验证草案 3 和 4。
您必须先使用JSON Validator Tool进行验证。