react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Empty value is not an option when using an optional field containing oneOf.

Open aurelien-brevet opened this issue 1 year ago • 1 comments

Prerequisites

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 avatar Jan 22 '24 14:01 aurelien-brevet

@aurelien-brevet You may have to disable html 5 validation to do what you want. Here is a playground with it working

heath-freenome avatar Jan 26 '24 20:01 heath-freenome