feat: improve support for minItems
and maxItems
for array layout and control #2387
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Added improved support for the
minItems
andmaxItems
properties, to allow for more fine-grained control and validation in ArrayControl and ArrayLayout applications. I have also added additional tests to cover these properties.While working on this, I realized that the current handling of array (or items) schemas is too restrictive for custom implementations. Specifically, the schema is being completely replaced by the items schema, which typically only includes a basic type description and hides important details like the
min
andmax
item properties from the original array schema.jsonforms/packages/core/src/mappers/renderer.ts
Lines 798 to 818 in fcef896
To address these limitations, I see two possible approaches:
parentSchema
property to preserve the original schema, keeping the existing behavior while easing the constraints. This might introduce some confusion around naming.schema
property and put the resolved schema in a newarraySchema
oritemsSchema
property. However, this would change the current behavior, requiring migration.I’d appreciate your thoughts on these options.