-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where matching anyOf branch is not selected correctly (#1129)
This change improves the logic that selects a matching anyOf branch based on form data. Previously the behaviour was to just check if the form data was valid against an anyOf branch, however due to the permissive nature of JSON schema this has unexpected behaviour. For example, given the following schema: ```json { "type": "object", "anyOf": [ { "properties": { "foo": { "type": "string" } } }, { "properties": { "bar": { "type": "string" } } } ] } ``` The form data `{ bar: 'baz' }` will actually match the first branch. To mitigate this, when doing the matching, the branch schema is augmented to require at least one of the keys in the branch. For example the schema above would become: ```json { "type": "object", "anyOf": [ { "properties": { "foo": { "type": "string" } }, "anyOf": [ { "required": [ "foo" ] } ] }, { "properties": { "bar": { "type": "string" } }, "anyOf": [ { "required": [ "bar" ] } ] } ] } ``` Signed-off-by: Lucian <lucian.buzzo@gmail.com>
- Loading branch information
1 parent
2685047
commit 2de683e
Showing
2 changed files
with
272 additions
and
1 deletion.
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