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.

support for wildcard in conditional schema dependency

See original GitHub issue

Prerequisites

Description

On the conditionals schema dependencies, how can I achieve having the conditional schema be displayed if corresponding enum array “contains” a value. Right now, it seems its only doing equality check and not supporting wildcards “*” etc.

Steps to Reproduce

For eg, in the schema, I have this property

"usageOptions": {
      "type": "array",
      "title": "Loan Usage Options",
      "items": {
        "type": "string",
        "enum": [
          "Other Home Addresses",
          "Refinance",
          "Home Improvement",
          "Education",
          "Other"
        ]
      },
      "uniqueItems": true
    },

And the conditional dependencies schema as

"dependencies": {
    "usageOptions": {
      "oneOf": [
        {
          "properties": {
            "usageOptions": {
              "items": {
                "enum": [
                  "Other"
                ]
              }
            },
            "othersDes": {
              "type": "string",
              "title": "Please describe others"
            }
          }
        }
      ]
    }
  }

Expected behavior

I want othersDes text field to appear when selected enum values “contains” Other option. So, in the multiple select list, no matter what user selects, if Other is part of selection, then, othersDes text field should display.

Actual behavior

The othersDes text field is appearing when only Other is selected.

Version

latest version “^1.2.0”

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
epicfaacecommented, Jan 25, 2019

You can use the contains keyword for this: playground link

2reactions
KKS1commented, Jan 25, 2019

Thank you so much @epicfaace . I used a combination of your suggestions to solve, and works like a charm. Here is how the dependency looks like, for anyone else facing this issue

dependencies: {
    usageOptions: {
      oneOf: [
        {
          properties: {
            usageOptions: {
              contains: {
                enum: ["Other"]
              }
            },
            othersDes: {
              type: "string",
              title: "Please describe others"
            }
          }
        }
      ]
    }
  }

This will make sure that conditional schema kicks in only when specifically, one if the enum options ( in this case Other is included the enum array.

Read more comments on GitHub >

github_iconTop Results From Across the Web

support for wildcard in conditional schema dependency #1155
On the conditionals schema dependencies, how can I achieve having the conditional schema be displayed if corresponding enum array "contains" a ...
Read more >
Applying Subschemas Conditionally - JSON Schema
The dependentSchemas keyword conditionally applies a subschema when a given property is present. This schema is applied in the same way allOf applies...
Read more >
Json Schema Conditional Dependency - United Hospital Services
Software foundation is json schema document data is also support json object? To change the dependencies keyword to use schema dependency.
Read more >
(PDF) Analyses and Validation of Conditional Dependencies ...
PDF | This paper proposes a natural extension of conditional func- tional dependencies (cfds (14)) and conditional inclusion dependencies ...
Read more >
Dependency specification | Documentation | Poetry - Python ...
Wildcard requirements allow for the latest (dependency dependent) version where the wildcard is positioned. * , 1.* and 1.2.* are examples of wildcard...
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