# No rule validation for "array contains value" when array undefined

**URL:** <https://jsonforms.discourse.group/t/no-rule-validation-for-array-contains-value-when-array-undefined/1308>\
**Category:** General\
**Created:** [February 8, 2023, 9:33pm UTC](https://jsonforms.discourse.group/t/no-rule-validation-for-array-contains-value-when-array-undefined/1308 "2023-02-08T21:33:44Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![clemens-msupply](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/clemens-msupply/32/633_2.png) [@clemens-msupply](https://jsonforms.discourse.group/u/clemens-msupply)\
**Post date:** [February 8, 2023, 9:33pm UTC](https://jsonforms.discourse.group/t/no-rule-validation-for-array-contains-value-when-array-undefined/1308/1 "2023-02-08T21:33:44Z")

</div>

I have a JSON schema that basically looks like:

```json
...
"properties: {
     "stringArray": {            
            "items": {
                "enum": ["Option1", "Option2", "Other"],
                "type": "string"
            },
            "type": "array"
      }
}

```

and a UI schema like:

```json
{
      "type": "Control",
      "scope": "#/properties/dependentControl",
      "rule": {
            "effect": "ENABLE",
            "condition": {
              "scope": "#/properties/stringArray",
              "schema": { "contains": { "const": "Other" } }
            }
      }
},

```

So I can select multiple values for the `stringArray` component and when the `stringArray` property contains “Other” (e.g. `stringArray = ["Option1", "Other"]` or `stringArray = ["Other"]`) I want to ENABLE the `dependentControl`.

This fails if the stringArray is not set and then the `dependentControl` is always ENABLED. Once I selected an enum value for `stringArray` everything starts working as expected (I guess because the stringArray is now set). It also continues working when I remove all items from `stringArray` again.

I have similar logic where I enable a control when a simple string property matches a certain value. This works even if the string control is not set. So something is different when using an array…

Any idea why it fails for this specific array case? could be an AJV problem?

---

_[View the full topic](https://jsonforms.discourse.group/t/no-rule-validation-for-array-contains-value-when-array-undefined/1308)._
