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
<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.
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 by Ricardo Guntur]