-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
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:
{ "power": 12 }
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:
{ "power": 42000 }
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).
pedrolopesme, handrews and thomask
Metadata
Metadata
Assignees
Labels
No labels