question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Would dependencies be complicated to implement?

https://spacetelescope.github.io/understanding-json-schema/reference/object.html#property-dependencies

I believe all scenarios of required fields would be covered.

If it’s too much work I’ll work around it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vincentmorneaucommented, Feb 14, 2017

That will do it for now.

I may look into automating the schema resolver. I’m sure it can all be done right from the original JSON Schema using the dependencies keyword.

Thanks again.

0reactions
mfulton26commented, Jul 15, 2017

I would like to be able to conditionally display questions declaratively and I believe this could be supported through dependencies as well. Does the following example make sense?

{
  "title": "Person",
  "type": "object",
  "properties": {
    "Do you have any pets?": {
      "type": "string",
      "enum": [
        "",
        "No",
        "Yes: One",
        "Yes: More than one"
      ]
    },
    "How old is your pet?": {
      "type": "number"
    },
    "How old is your oldest pet?": {
      "type": "number"
    }
  },
  "required": [
    "Do you have any pets?"
  ],
  "dependencies": {
    "Do you have any pets?": {
      "oneOf": [
        {
          "properties": {
            "Do you have any pets?": {
              "enum": [
                "",
                "No"
              ]
            },
            "How old is your pet?": {
              "not": {}
            },
            "How old is your oldest pet?": {
              "not": {}
            }
          }
        },
        {
          "properties": {
            "Do you have any pets?": {
              "enum": [
                "Yes: One"
              ]
            },
            "How old is your oldest pet?": {
              "not": {}
            }
          },
          "required": [
            "How old is your pet?"
          ]
        },
        {
          "properties": {
            "Do you have any pets?": {
              "enum": [
                "Yes: More than one"
              ]
            },
            "How old is your pet?": {
              "not": {}
            }
          },
          "required": [
            "How old is your oldest pet?"
          ]
        }
      ]
    }
  }
}

If “Do you have any pets?” is “” or “No” then no further questions are present nor required; if it is “Yes: One” then “How old is your pet?” is present and required but “How old is your oldest pet?” is not; if it is “Yes: More than one” then “How old is your oldest pet?” is present and required but “How old is your pet?” is not.

This would support dynamic schemas without the need for a schema resolver which would simplify things, especially when array objects need to be dynamic, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a Dependency? Dependency Definition and Examples
A dependency describes the relationship among activities and specifies the particular order in which they need to be performed. Dependencies arise in every ......
Read more >
Dependencies in Project Management (Examples + Expert Tips)
Dependencies are any task, occurrence, or condition: That depends on the completion of a former task; Or, on which a successor task is...
Read more >
Understanding dependencies in project management - Asana
A project dependency is a task that relies on the completion of a different task. This article discusses different dependencies in project ...
Read more >
What are dependencies in project management ... - Workzone
In the world around you, a dependency is the state of existence of an entity or an item such that its stability is...
Read more >
Dependency Definition & Meaning - Merriam-Webster
The meaning of DEPENDENCY is dependence. How to use dependency in a sentence. ... plural dependencies. 1. : dependence sense 1.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found