Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BenjaminVerble/beb04f1e78f3446dede5e6ddc67be8bd to your computer and use it in GitHub Desktop.
Save BenjaminVerble/beb04f1e78f3446dede5e6ddc67be8bd to your computer and use it in GitHub Desktop.
react-jsonschema-form-conditionals example
import Engine from "json-rules-engine-simplified";
const conf = {
schema: {
type: "object",
properties: {
general: {
type: "object",
properties: {
a: {
type: "boolean",
title: "A",
},
aDescription: {
type: "string",
title: "Description of A (if a true)",
},
},
},
},
},
uiSchema: {
general: {
"ui:order": ["a", "aDescription"],
},
},
formData: {
a: "adming",
heightMeasure: "cms",
weight: 117,
weightMeasure: "Kgs",
},
rules: [
{
conditions: {
or: [
{
"general.a": { is: null },
},
{
"general.a": { is: undefined },
},
{
"general.a": { is: false }
}
]
},
event: {
type: "remove",
params: {
field: ["general.aDescription"],
},
},
},
],
rulesEngine: Engine,
};
export default conf;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment