react-jsonschema-form
react-jsonschema-form copied to clipboard
Issue with oneOf Validation in rjsf
Prerequisites
- [X] I have read the documentation
What theme are you using?
validator-ajv8
What is your question?
I'm working with a schema that uses the oneOf
keyword to define two options, each with its own set of required fields. However, I'm encountering an issue where, after selecting one option and entering values, the validator incorrectly prompts for required fields from the other option.
Here’s a simplified example of my schema:
{
"oneOf": [
{
"type": "object",
"properties": {
"optionAField1": { "type": "string" },
"optionAField2": { "type": "number" }
},
"required": ["optionAField1"]
},
{
"type": "object",
"properties": {
"optionBField1": { "type": "string" },
"optionBField2": { "type": "number" }
},
"required": ["optionBField1"]
}
]
}
When I select the first option and fill in optionAField1, I receive a validation error indicating that optionBField1 is required, even though it should not be necessary for the chosen option.
Is this a known issue with rjsf, or am I missing something in my schema configuration? How can I resolve this issue?