2

下面是我的与 jsonschema 4.0 兼容的 json 模式。

{
"type": "object",
"properties": {
    "name": { "type": "string" },
    "credit_card": { 
        "type": "number" ,
        "id":"credit_card"
    },
    "billing_address": {
        "type": "string" ,
        "id":"billing_address"
    }
},
"required": ["name"],
"dependencies": [{
    "credit_card": ["billing_address"]
}]

}

dependencies在那里不起作用,即每当提供信用卡详细信息时,生成的表格也应要求提供 billing_address。虽然字段显示正确,但填写 credit_card 详细信息时不会显示验证错误。 在此处输入图像描述

我们已启用验证interaction 是我做错了还是存在某些版本问题。请注意,我现在还没有指定 $schema。

有什么帮助吗?

4

1 回答 1

1

dependencies不应包装在数组中。将您更改dependencies为:

"dependencies": {
    "credit_card": ["billing_address"]
}

这将使您的架构有效,但这并不能保证您使用的表单生成器支持该dependencies关键字。通常它们只支持 JSON Schema 规范的一个子集。

于 2016-01-30T00:21:52.143 回答