Skip to content

group-array with required parent fails for empty array, despite minItems: 0 #247

Description

@mariada-ta

Description:
I’m using remotess json-schema-form in my vue project. The schema I created has a parent array property ("inputType": "group-array") which is required, but the array itself can be empty (minItems: 0).

Look here:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "sources": {
      "title": "Sources",
      "type": "array",
      "x-jsf-presentation": {
        "inputType": "group-array",
        "min": 0,
        "max": 61
      },
      "items": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer",
            "title": "index",
            "minimum": 1,
            "maximum": 62,
            "x-jsf-presentation": {
              "inputType": "number",
              "min": 1,
              "max": 62
            }
          },
          "device": {
            "type": "integer",
            "title": "Device",
            "minimum": 1,
            "maximum": 62,
            "x-jsf-presentation": {
              "inputType": "number",
              "default": 1,
              "min": 1,
              "max": 62
            }
          }
        },
        "required": [
          "device",
          "index"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "maxItems": 61,
      "uniqueItems": true
    }
  },
  "required": [
    "sources"
  ],
  "additionalProperties": false
}

Problem:
When I validate the following json: {"sources":[]} it always says {"sources":"Required field"} and the problem is only gone, when I remove the "required": [
"sources"
]

I added a small vue example showing my issue, I would appreciate every bit of help.

bug_empty_required_json.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions