Here's a helpful post on the capabilities in JSON schema.
Here are the cases to handle:
Is defined
a:
Data Type: "Boolean"
Required: True
b:
Data Type: "Numeric"
Required: "if a"
c:
Data Type: "Numeric"
Required: True
gives
{
"type": "object",
"properties": {
"a": { "type": "boolean" },
"b": { "type": "number" },
"c": { "type": "number" }
},
"required": ["a", "c"],
"dependencies": {
"a": ["b"]
}
}
Is equal
a:
Data Type: "Boolean"
Required: True
b:
Data Type: "Numeric"
Required: "if a=False"
c:
Data Type: "Numeric"
Required: True
gives
{
"type": "object",
"properties": {
"a": { "type": "boolean" },
"b": { "type": "number" },
"c": { "type": "number" }
},
"required": ["a", "c"],
"if": {
"properties": {
"a": { "const": false}
}
},
"then": { "required": ["b"] }
}
Is not equal
a:
Data Type: "Boolean"
Required: True
b:
Data Type: "Numeric"
Required: "if a!=False"
c:
Data Type: "Numeric"
Required: True
gives
{
"type": "object",
"properties": {
"a": { "type": "boolean" },
"b": { "type": "number" },
"c": { "type": "number" }
},
"required": ["a", "c"],
"if": {
"properties": {
"a": { "not": {"const": false} }
}
},
"then": { "required": ["b"] }
}
We may be able to find ways to combine these too. But I think covering these cases for now should be fine.
Here's a helpful post on the capabilities in JSON schema.
Here are the cases to handle:
Is defined
gives
{ "type": "object", "properties": { "a": { "type": "boolean" }, "b": { "type": "number" }, "c": { "type": "number" } }, "required": ["a", "c"], "dependencies": { "a": ["b"] } }Is equal
gives
{ "type": "object", "properties": { "a": { "type": "boolean" }, "b": { "type": "number" }, "c": { "type": "number" } }, "required": ["a", "c"], "if": { "properties": { "a": { "const": false} } }, "then": { "required": ["b"] } }Is not equal
gives
{ "type": "object", "properties": { "a": { "type": "boolean" }, "b": { "type": "number" }, "c": { "type": "number" } }, "required": ["a", "c"], "if": { "properties": { "a": { "not": {"const": false} } } }, "then": { "required": ["b"] } }We may be able to find ways to combine these too. But I think covering these cases for now should be fine.