Condtion to check against array of strings

I’m trying to realize a survey with JSONForms.
Hi there… sorry for the lame question… json-schema noob here.

I’ve got a string property with an array of enumables as values…

"current_bills": {
    "title": "Attuali Utenze",
    "type": "array",
    "items": {
        "type": "string",
        "enum": ["Luce", "Gas", "Telefono fisso", "Telefono mobile", "Noleggio Auto", "Altro" ]
    }
}

I’d like to make a condition to show a group of fields (or a single one like shown in my sample code) only if the scoped property array contains a specific field (i.e. “Gas”)

Here’s my ui schema entry:

{
    "type": "Control",
    "scope": "#/properties/gas_detail",
    "label": "Dettaglio Gas",
    "rule": {
        "effect": "SHOW",
        "condition": {
            "scope": "#/properties/current_bills",
            "schema": {
                WhatCondition?
            }
        }
    }
}

I’d be glad if someone could points me to a possible solution, or helps me understanding better the SchemaBasedCondition interface.

Honestly I was a bit overwhelmed by JSONForms and json-schema docs.

Thanks in advance

[original thread by blabs-dev]

[blabs-dev]

I found an answer here, but i just can’t find any reference on the docs about this contains keyword.

[blabs-dev]

Problem solved… here’s my rule:

"rule": {
"effect": "SHOW",
"condition": {
  "scope": "#/properties/current_bills",
  "schema": { 
    "type": "array",
    "contains": {
      "enum": ["Gas"]
    } 
  }
}

Hi @blabs-dev(blabs-dev), great that you managed to find a solution :slight_smile: The reason we don’t document contains on our website is because it is part of the official JSON Schema specification. Usually I recommend Understanding JSON Schema as a more accessible read than the pure specification, however I don’t know whether that book actually covers contains.