Skip to content

Instantly share code, notes, and snippets.

@mediawrangler
Created January 9, 2019 18:16
Show Gist options
  • Save mediawrangler/2f5e97c6ae66c37501b6f1dd0d113b5d to your computer and use it in GitHub Desktop.
Save mediawrangler/2f5e97c6ae66c37501b6f1dd0d113b5d to your computer and use it in GitHub Desktop.
React JSON Schema Form - Conditionals (Schema Dependency)
{
"title": "A registration form",
"description": "A simple form example.",
"type": "object",
"properties": {
"hasMiddleName": {
"type": "boolean",
"title": "Has Middle Name?"
},
"lastName": {
"type": "string",
"title": "Last Name",
"default": "Lynch"
},
"firstName": {
"type": "string",
"title": "First Name",
"default": "Travis"
}
},
"dependencies": {
"hasMiddleName": {
"oneOf": [
{
"properties": {
"hasMiddleName": {
"enum": [
true
]
},
"middleName": {
"type": "string",
"title": "Middle Name"
}
}
},
{
"properties": {
"hasMiddleName": {
"enum": [
false
]
}
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment