react-jsonschema-form
react-jsonschema-form copied to clipboard
Empty value is not an option when using an optional field containing oneOf.
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [ ] Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
core
Version
5.x
Current Behavior
The field firstName is optional but an option is required. Cannot leave it empty.
Expected Behavior
Leave the field firstName empty.
Steps To Reproduce
{
"type": "object",
"properties": {
"firstName": {
"oneOf": [
{
"type": "object",
"properties": {
"test": {
"type": "string"
}
},
"required": [
"test"
]
},
{
"type": "object",
"properties": {
"test": {
"type": "number"
}
},
"required": [
"test"
]
}
]
}
}
}
### Environment
```markdown
- OS:
- Node:
- npm:
Anything else?
No response
@aurelien-brevet You may have to disable html 5 validation to do what you want. Here is a playground with it working