# How can I disable allowedValues validation for enums?

**URL:** <https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219>\
**Category:** General\
**Created:** [October 19, 2020, 7:09pm UTC](https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219 "2020-10-19T19:09:55Z")\
**Posts on this page:** 5\
**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:** [October 19, 2020, 7:09pm UTC](https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219/1 "2020-10-19T19:09:55Z")

</div>

Hi Team!

I can’t figure out how to disable the allowedValues validation for enums. Any help would be appreciated.

We’re trying to setup a multiselect using a custom mui renderer using an array of objects. The object being values and labels. We’re not able to use the object itself as the select value because mui doesn’t seem to match it properly.

Here is a snippet of our custom renderer

```auto
            <Select
                style={{ minWidth: '6em', maxWidth: '50%' }}
                classes={{
                    selectMenu: classes.selectMenu,
                }}
                value={values}
                onChange={doChange}
                fullWidth={false}
                multiple={true}
                label={uischema.label || ''}
            >
                {enums.map(option => {
                    return (
                        // We must pass the entire scope object to abide by jsonforms default enum validation: allowedValues
                        <MenuItem
                            value={option.value}
                            key={option.value}
                            // checked={values && values.indexOf(option.value) > -1}
                            children={option.label}
                        />
                    )
                })}
            </Select>

```

As you can see the `option.value` is different from the `option.label` which are defined in the schema dynamically. Because the value does not match the schema, I’m getting this allowedValues error.

```auto
data: "value placeholder2"
dataPath: "colors.0"
keyword: "enum"
message: "should be equal to one of the allowed values"
params:
allowedValues: Array(3)
0: {label: "placeholder1", value: "value placeholder1"}
1: {label: "placeholder2", value: "value placeholder2"}
2: {label: "placeholder3", value: "value placeholder3"}
length: 3
__proto__ : Array(0)
__proto__ : Object

```

_[[original thread](https://spectrum.chat/jsonforms/general/how-can-i-disable-allowedvalues-validation-for-enums~93163f43-ef3e-4abe-9b20-164bd3b30a86) by Ricardo Guntur]_

---

<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:** [October 19, 2020, 7:26pm UTC](https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219/2 "2020-10-19T19:26:27Z")

</div>

_[Ricardo Guntur]_

Another thought. This wouldn’t be an issue if I could set the object as the options themselves. But the select component doesn’t not recognize the saved values for some reason. I think it’s an issue about object reference comparison.

---

<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:** [October 19, 2020, 7:48pm UTC](https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219/3 "2020-10-19T19:48:34Z")

</div>

_[Ricardo Guntur]_

![](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/422a0c774a175726335a161243013538bb9bd8e5.png)

---

<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:** [October 19, 2020, 7:48pm UTC](https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219/4 "2020-10-19T19:48:35Z")

</div>

_[Ricardo Guntur]_

When I used objects, I compared the saved value with the options in the actual select component and its false.

---

<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:** [October 19, 2020, 8:02pm UTC](https://jsonforms.discourse.group/t/how-can-i-disable-allowedvalues-validation-for-enums/219/5 "2020-10-19T20:02:08Z")

</div>

_[Ricardo Guntur]_

Okay I see that using `enum` as the prop name in the schema automatically sets the `allowedValues` magically. Not sure if that is a jsonforms thing or default jsonschem/ajv thing. Searching `allowedValues` in the jsonforms package for `allowedValues` only yields tests.

Since it’s a custom renderer I don’t need to use enum and just renamed it options. This seems to work, not sure if I will lose other functionality yet. My `minItems` validation still works. The only thing that doesn’t work is that there is no validation before I touch the component.
