我的jsonSchema如下所示
[{
"path": [
"General",
"label"
],
"type": "label",
"label": "Calculate Losses From Sub-Peril(s)",
"required": true
},
{
"path": [
"General",
"fire"
],
"type": "boolean",
"default": true,
"label": "Fire"
},
{
"path": [
"General",
"fireSmoke"
],
"type": "boolean",
"default": false,
"label": "Fire and Smoke"
}
],我有如下的jsonSchema规则。因此,如果用户取消选中fire和Fire and Smoke,我希望触发一个通知。如何定义JsonSchema规则。有人能解决这个问题吗?我有下面的规则,但它给了我解析器错误。必须至少选中一个复选框。
{
"path": [
"General",
"fire"
],
"effect": "fireNotification",
"notification": {
"type": "warning",
"message": "At least one Sub-Peril must be selected",
"notificationID": "fire",
"dismissible": "false"
},
"condition": {
"operator": "oneOf": {
"properties": {
"fire": {
"enum": [
true
]
},
"fireSmoke": {
"enum": [
true
]
}
}
}
}
}发布于 2020-05-21 06:48:35
您的JSON在两个方面是无效的,这两个方面都在同一行上:
"operator": "oneOf": {
"operator":之后,您需要另一个左大括号({) (以及稍后匹配的右大括号。"oneOf":的值应该是一个数组,因此您需要在其中添加一个左括号([) (以及稍后添加一个匹配的右括号)。此外,您说“至少必须选中一个复选框”,但您使用的是"oneOf“规则,而不是"anyOf”。使用"oneOf“时,如果两个属性都为真,则验证将失败。
https://stackoverflow.com/questions/61923958
复制相似问题