Skip to content

JSON schema validation with multiple conditions #904

Answered by gregsdennis
emanuelenasoae asked this question in Q&A
Discussion options

You must be logged in to vote

One tactic that I've found works well is to use the hierarchical ("verbose", maybe) format and follow the valid: falses. As you go deeper into the tree, you can ignore the valid: trues because they're not the problem (unless you have a not keyword).

This process will highlight the problems you need to fix. Any "false positives" will occur in failed subschemas from within passing subschemas.

Schema

{
  "anyOf": [
    {"type": "integer"},
    {"type": "string"}
  ]
}

Instance: "dog"

Output:

{
  "valid": true,
  "evaluationPath": "",
  "schemaLocation": "https://json-everything.net/f14e9c0a25#",
  "instanceLocation": "",
  "details": [
    {
      "valid": false,
      "evaluationPath": "/an…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@gregsdennis
Comment options

@emanuelenasoae
Comment options

@emanuelenasoae
Comment options

@gregsdennis
Comment options

@emanuelenasoae
Comment options

Answer selected by emanuelenasoae
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