How can I disable allowedValues validation for enums?

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

                style={{ minWidth: '6em', maxWidth: '50%' }}
                    selectMenu: classes.selectMenu,
                label={uischema.label || ''}
                { => {
                    return (
                        // We must pass the entire scope object to abide by jsonforms default enum validation: allowedValues
                            // checked={values && values.indexOf(option.value) > -1}

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.

data: "value placeholder2"
dataPath: "colors.0"
keyword: "enum"
message: "should be equal to one of the allowed values"
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 by Ricardo Guntur]

[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.

[Ricardo Guntur]

[Ricardo Guntur]

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

[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.