Skip to content

Incorrectly Applying 'if-then' Condition to Nested Definition #497

Closed Answered by Relequestual
mfialaf asked this question in Q&A
Discussion options

You must be logged in to vote

No problem, we got you.
This becomes easier to understand when you think about applicability and applicators.
Both if and then are applicator keywords, as is properties and items.

You got close on your second try. What you have to consider is you need to define if and then at the level at which it can see down to all locations in the instance it needs to know about.

Your then clause needs to look like this:

"then": {
  "properties": {
    "tools": {
      "items": {
        "not": {
          "required": [
            "name"
          ]
        }
      }
    }
  }
}

You can see it working here: https://jsonschema.dev/s/Z8UqI

If you want to understand more about how to think with applicat…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mfialaf
Comment options

You must be logged in to vote
5 replies
@Relequestual
Comment options

@mfialaf
Comment options

@Relequestual
Comment options

@mfialaf
Comment options

@Relequestual
Comment options

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