Draft 7 of JSON Schema addes Keywords for Applying Subschemas Conditionally.
It would be amazing to add support for if/then/else to liform-react. e.g.:
schema:
{
"properties": { "power": { "type": "integer" } },
"if": { "properties": { "power": { "const": 9000 } } },
"then": { "properties": { "disbelief": { "type": "boolean" } } },
"else": { "properties": { "confidence": { "type": "string" } } }
}
data 1:
form 1:
<form>
<label for="field-power">power</label>
<input id="field-power" type="number" step="1"/>
<label for="field-disbelief">disbelief</label>
<input id="field-disbelief" type="checkbox"/>
</form>
data 2:
form 1:
<form>
<label for="field-power">power</label>
<input id="field-power" type="number" step="1"/>
<label for="field-confidence">confidence</label>
<input id="field-confidence" type="text"/>
</form>
Basically, if the if schema is valid then the then schema is applied, otherwise the else schema is applied (if else is defined).
Draft 7 of JSON Schema addes Keywords for Applying Subschemas Conditionally.
It would be amazing to add support for if/then/else to liform-react. e.g.:
schema:
{ "properties": { "power": { "type": "integer" } }, "if": { "properties": { "power": { "const": 9000 } } }, "then": { "properties": { "disbelief": { "type": "boolean" } } }, "else": { "properties": { "confidence": { "type": "string" } } } }data 1:
form 1:
data 2:
form 1:
Basically, if the
ifschema is valid then thethenschema is applied, otherwise theelseschema is applied (ifelseis defined).