Skip to content

fix(jsonforms-renderers): show required asterisk and errors on ArrayControl - #118

Merged
ginaxu1 merged 4 commits into
mainfrom
fix/jsonforms-array-required-asterisk
Oct 16, 2026
Merged

ginaxu1 merged 4 commits into
mainfrom
fix/jsonforms-array-required-asterisk

Conversation

@ginaxu1

@ginaxu1 ginaxu1 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Resolves https://github.com/LSFLK/lsf-govtech-tnsw/issues/191

Summary

  • ArrayControl shows a red asterisk when the array is required (including via allOf/if/then through useIsRequired) or has minItems of at least 1.
  • minItems >= 1 is a separate rule from schema required: an empty array fails with a minItems error, not a required error, so the asterisk still shows for that case.
  • Validation errors on the array are rendered under the title. uiSchema options.errorMessage replaces the default message only when the array is empty (required / minItems); other errors (e.g. maxItems) keep AJV's wording.
  • Playground array fixture uses minItems: 1 and options.errorMessage.

Release notes

Array fields now show a red * when they are required or have minItems of at least 1, and show their validation error under the title. A new uiSchema option errorMessage replaces the default message when the array is empty.

Test plan

  • Open a form with a required array (or minItems: 1) and confirm the title shows a red asterisk.
  • Submit with an empty array and confirm the inline error appears (custom message when options.errorMessage is set).
  • Add an item and confirm the error clears.
  • Existing array add/remove behaviour is unchanged.
  • Playground Array (objects) fixture shows * and custom empty-array error after removing all items.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b99df72-ba17-48a7-a0a2-f11ee1b548d6
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added Package/jsonforms-renderers Changes to packages/jsonforms-renderers Type/Bug Something isn't working as expected labels Oct 15, 2026
@sthanikan2000 sthanikan2000 changed the title fix(jsonforms): show required asterisk and errors on ArrayControl fix(jsonforms-renderers): show required asterisk and errors on ArrayControl Oct 16, 2026
sthanikan2000
sthanikan2000 previously approved these changes Oct 16, 2026

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ginaxu1. I edited the title (scope jsonforms-renderers) and added a Release notes section to the description, since the release script reads it and this adds a new uiSchema option; please keep both. Tests pass locally (562) and type-check is clean. Approving; the inline comments are non-blocking.

Comment thread packages/jsonforms-renderers/src/renderers/ArrayControl.tsx Outdated
Comment thread packages/jsonforms-renderers/src/renderers/ArrayControl.tsx Outdated
Comment thread packages/jsonforms-renderers/src/renderers/ArrayControl.tsx
ginaxu1 and others added 4 commits October 15, 2026 23:00
Array fields with required or minItems had no red asterisk and ignored
validation errors, so empty required lists failed silently in the UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Partial<ArrayControlProps> type-checked draft-04 JsonSchema fixtures
against JsonSchema7 and failed CI type-check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Use the #112 hook for conditional required, keep the separate minItems
asterisk rule, limit options.errorMessage to empty arrays, and expose
both in the array playground fixture.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ginaxu1
ginaxu1 force-pushed the fix/jsonforms-array-required-asterisk branch from 468cd29 to 2c5315c Compare October 16, 2026 06:01
@ginaxu1
ginaxu1 requested a review from sthanikan2000 October 16, 2026 06:05

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked after the rebase, and thanks for taking all three comments. I rendered it with real JsonForms: an array required through if/then gets the *, an empty minItems array shows the custom message, maxItems keeps AJV's wording, and the playground fixture shows the *. 586 tests pass and type-check is clean. Approving.

Non-blocking: the unit tests mock useIsRequired, so the conditional-array behaviour isn't covered by a committed test. One render test with the real provider (a schema with allOf/if/then requiring the array) would pin it.

@ginaxu1
ginaxu1 merged commit 37f85d6 into main Oct 16, 2026
7 checks passed
@ginaxu1
ginaxu1 deleted the fix/jsonforms-array-required-asterisk branch October 16, 2026 06:20
@ginaxu1 ginaxu1 self-assigned this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Package/jsonforms-renderers Changes to packages/jsonforms-renderers Type/Bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants