Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support applying subschemas conditionally #40

Open
mfulton26 opened this issue Mar 23, 2018 · 0 comments
Open

Support applying subschemas conditionally #40

mfulton26 opened this issue Mar 23, 2018 · 0 comments

Comments

@mfulton26
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant