# Condtion to check against array of strings

**URL:** <https://jsonforms.discourse.group/t/condtion-to-check-against-array-of-strings/242>\
**Category:** General\
**Created:** [February 7, 2021, 1:29pm UTC](https://jsonforms.discourse.group/t/condtion-to-check-against-array-of-strings/242 "2021-02-07T13:29:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [February 7, 2021, 1:29pm UTC](https://jsonforms.discourse.group/t/condtion-to-check-against-array-of-strings/242/1 "2021-02-07T13:29:57Z")

</div>

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…

```auto
"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:

```auto
{
    "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](https://spectrum.chat/jsonforms/general/condtion-to-check-against-array-of-strings~ac320778-a9da-4d1a-ba9b-5c47bd7c5db9) by blabs-dev]_

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [February 7, 2021, 2:36pm UTC](https://jsonforms.discourse.group/t/condtion-to-check-against-array-of-strings/242/2 "2021-02-07T14:36:47Z")

</div>

_[blabs-dev]_

I found an answer [here](https://github.com/eclipsesource/jsonforms/issues/1141#issuecomment-436386380), but i just can’t find any reference on the docs about this _contains_ keyword.

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [February 7, 2021, 2:40pm UTC](https://jsonforms.discourse.group/t/condtion-to-check-against-array-of-strings/242/3 "2021-02-07T14:40:11Z")

</div>

_[blabs-dev]_

Problem solved… here’s my rule:

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

```

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [February 8, 2021, 12:14pm UTC](https://jsonforms.discourse.group/t/condtion-to-check-against-array-of-strings/242/4 "2021-02-08T12:14:07Z")

</div>

Hi @blabs-dev(blabs-dev), great that you managed to find a solution 🙂 The reason we don’t document _contains_ on our website is because it is part of the official [JSON Schema specification](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4). Usually I recommend [Understanding JSON Schema](https://json-schema.org/understanding-json-schema/index.html) as a more accessible read than the pure specification, however I don’t know whether that book actually covers contains.
