Skip to content

Switching and Validating Schemas based on attribute value #635

Closed Answered by gregsdennis
mathan-mohan91 asked this question in Q&A
Discussion options

You must be logged in to vote

The likely issue is that your subschemas are missing a properties. For example, the if subschemas needs a properties outside of group. Currently it looks like group is a keyword, and since it's unknown it'll just be ignored, making the if always validate.

Also, you'll want to make group required in the if subschema if it's possible that group could be missing.

"if": {
  "properties": {
    "group" : {
      "const" : "user"
    }
  },
  "required": ["group"]
},
...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mathan-mohan91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants