-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from adithya321/required-only-if-visible
throw required error only if property is visible
- Loading branch information
Showing
3 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
src/app/json-schema-example/required-only-if-visible.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
{ | ||
"properties": { | ||
"checkbox": { | ||
"type": "boolean", | ||
"title": "Checkbox", | ||
"widget": "checkbox" | ||
}, | ||
"select": { | ||
"type": "string", | ||
"title": "Select", | ||
"widget": "select", | ||
"oneOf": [ | ||
{ | ||
"description": "Option #1", | ||
"enum": ["Option #1"] | ||
}, | ||
{ | ||
"description": "Option #2", | ||
"enum": ["Option #2"] | ||
}, | ||
{ | ||
"description": "Option #3", | ||
"enum": ["Option #3"] | ||
} | ||
], | ||
"visibleIf": { | ||
"checkbox": [true] | ||
} | ||
}, | ||
"multi-select": { | ||
"type": "array", | ||
"title": "Multi Select", | ||
"widget": "select", | ||
"minItems": 2, | ||
"items": { | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"description": "Option #1", | ||
"enum": ["Option #1"] | ||
}, | ||
{ | ||
"description": "Option #2", | ||
"enum": ["Option #2"] | ||
}, | ||
{ | ||
"description": "Option #3", | ||
"enum": ["Option #3"] | ||
} | ||
] | ||
}, | ||
"visibleIf": { | ||
"checkbox": [true] | ||
} | ||
}, | ||
"string": { | ||
"type": "string", | ||
"title": "String - Visible if Checkbox is checked", | ||
"visibleIf": { | ||
"checkbox": [true] | ||
} | ||
}, | ||
"number": { | ||
"type": "number", | ||
"title": "Number - Visible if String is 'a'", | ||
"widget": "number", | ||
"visibleIf": { | ||
"string": ["a"] | ||
} | ||
}, | ||
"array": { | ||
"type": "array", | ||
"title": "Array", | ||
"minItems": 2, | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"array-checkbox": { | ||
"type": "boolean", | ||
"title": "Checkbox", | ||
"widget": "checkbox" | ||
}, | ||
"array-select": { | ||
"type": "string", | ||
"title": "Select", | ||
"widget": "select", | ||
"oneOf": [ | ||
{ | ||
"description": "Option #1", | ||
"enum": ["Option #1"] | ||
}, | ||
{ | ||
"description": "Option #2", | ||
"enum": ["Option #2"] | ||
}, | ||
{ | ||
"description": "Option #3", | ||
"enum": ["Option #3"] | ||
} | ||
], | ||
"visibleIf": { | ||
"array-checkbox": [true] | ||
} | ||
}, | ||
"array-multi-select": { | ||
"type": "array", | ||
"title": "Multi Select", | ||
"widget": "select", | ||
"minItems": 2, | ||
"items": { | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"description": "Option #1", | ||
"enum": ["Option #1"] | ||
}, | ||
{ | ||
"description": "Option #2", | ||
"enum": ["Option #2"] | ||
}, | ||
{ | ||
"description": "Option #3", | ||
"enum": ["Option #3"] | ||
} | ||
] | ||
}, | ||
"visibleIf": { | ||
"array-checkbox": [true] | ||
} | ||
}, | ||
"array-string": { | ||
"type": "string", | ||
"title": "String - Visible if Checkbox is checked", | ||
"visibleIf": { | ||
"array-checkbox": [true] | ||
} | ||
}, | ||
"array-number": { | ||
"type": "number", | ||
"title": "Number - Visible if String is 'a'", | ||
"widget": "number", | ||
"visibleIf": { | ||
"array-string": ["a"] | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"array-select", | ||
"array-multi-select", | ||
"array-string", | ||
"array-number" | ||
] | ||
} | ||
} | ||
}, | ||
"required": ["select", "multi-select", "string", "number", "array"] | ||
} |