Skip to content

React JSON Schema Form doesn't support minItems property in array validation #4663

@Swastik19Nit

Description

@Swastik19Nit

Description

When using React JSON Schema Form with JSON Schema that includes minItems property for array validation, the form doesn't properly enforce the minimum items requirement.

Current Behavior

  • When a JSON Schema includes minItems property for arrays, React JSON Schema Form ignores this validation
  • Arrays can be empty even when minItems is set to a value greater than 0
  • No validation errors are shown to users when array length is less than minItems

Expected Behavior

  • React JSON Schema Form should respect the minItems property in JSON Schema
  • Forms should prevent arrays from having fewer items than specified in minItems
  • Validation errors should be shown when array length is less than minItems

Example Schema

{
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    }
  }
}

Additional Context

This is a common requirement in forms where certain arrays must have at least one item. The minItems property is a standard part of JSON Schema validation, and it would be beneficial if React JSON Schema Form supported this validation rule.

Possible Workarounds

Currently, we're handling this by:

  1. Adding custom validation
  2. Using required property (though this doesn't enforce minimum items)
  3. Implementing custom array field templates

Impact

This limitation affects form validation where arrays must have a minimum number of items, which is a common requirement in many applications.

Additional Notes

This is not a bug in the traditional sense, but rather a missing feature that would improve the library's compliance with JSON Schema standards.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions