【发布时间】:2019-10-12 23:23:32
【问题描述】:
我想根据其他一些属性的值有条件地添加。 只有在“isInexperienced”时才需要“companyName”和“companyAddress” 值为假。
架构
{
"type": "object",
"properties": {
"previous_employment_section": {
"type": "array",
"items": {
"type": "object",
"properties": {
"companyAddress": {
"type": "string"
},
"companyName": {
"type": "string"
}
},
"if": {
"#/properties/isInexperienced": {
"const": false
}
},
"then": {
"required": [
"companyName",
"companyAddress"
]
}
}
},
"isInexperienced": {
"type": "boolean"
}
}
}
数据
{
"previous_employment_section": [],
"isInexperienced": true
}
【问题讨论】:
标签: javascript json object ajv