# Rule for multi-select enum not working

**URL:** <https://jsonforms.discourse.group/t/rule-for-multi-select-enum-not-working/959>\
**Category:** General\
**Created:** [August 19, 2022, 6:00am UTC](https://jsonforms.discourse.group/t/rule-for-multi-select-enum-not-working/959 "2022-08-19T06:00:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbieJson](https://avatars.discourse-cdn.com/v4/letter/n/4bbf92/32.png) [@newbieJson](https://jsonforms.discourse.group/u/newbieJson)\
**Post date:** [August 19, 2022, 6:00am UTC](https://jsonforms.discourse.group/t/rule-for-multi-select-enum-not-working/959/1 "2022-08-19T06:00:46Z")

</div>

1. A boolean to trigger “SHOW” a multi-select arrary.  
 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/569d07aaed6a40c5a7dd68b889e46b950db3c781.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/912bde144a38229f24bb1ca191967b110f3638b9.png)

2. User select “foo” checkbox. It should “SHOW” a textfield below the multi-select array.  
 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/aac1cc5c38914890ada68c77ca974882688dbbde.png)

schema.json

```auto
{
  "type": "object",
  "properties": {
"boolean":{
      "type":"boolean"
    },
    "multiEnum": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "foo",
          "bar",
          "foobar"
        ]
      }
    },
    "textField":{
      "type":"string"
    }
}
}

```

uiSchema.json

```auto
{
  "type": "VerticalLayout",
  "elements": [
{
      "type": "Control",
      "scope": "#/properties/boolean"
    },
    {
      "type": "Control",
      "scope": "#/properties/multiEnum",
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#properties/boolean",
          "schema": {
            "const": true
          }
        }
      }
    },
    {
      "type": "Control",
      "scope": "#/properties/textField",
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#properties/multiEnum",
          "schema": { "enum": ["foo"] }
        }
      }
    }
 ]
}

```

---

<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:** [August 19, 2022, 6:55am UTC](https://jsonforms.discourse.group/t/rule-for-multi-select-enum-not-working/959/2 "2022-08-19T06:55:08Z")

</div>

Hi @newbieJson,

The `condition.schema` in the UI Schema does not match the JSON Schema, therefore it will never apply the `"SHOW"` rule, i.e.

- The JSON Schema defines `multiEnum` as `type: 'array'`, so valid values are for example `["foo", "bar"]` and `[]`.
- In the UI Schema `enum: ["foo"]` is used, therefore the only valid value is `"foo"`.

As one describes the value as an array and the other just as a single string this will never match.

If you want to match when only `foo` is selected then you could use `enum: [["foo"]]`. Then the only valid value is an array containing “foo”. If you want to match when `foo` is selected but any other value could be selected too, then you will need to enumerate all possibilities or use a `not` and enumerate all counter possibilities.

I can recommend online JSON Schema validators like [this one](https://www.jsonschemavalidator.net/) so you can test your JSON Schemas before using them in JSON Forms.
