Repository navigation
fix(jsonforms-renderers): show required asterisk and errors on ArrayControl - #118
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
sthanikan2000
left a comment
There was a problem hiding this comment.
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.
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>
468cd29 to
2c5315c
Compare
sthanikan2000
left a comment
There was a problem hiding this comment.
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.
Resolves https://github.com/LSFLK/lsf-govtech-tnsw/issues/191
Summary
allOf/if/thenthroughuseIsRequired) or hasminItemsof at least 1.minItems >= 1is a separate rule from schemarequired: an empty array fails with aminItemserror, not arequirederror, so the asterisk still shows for that case.options.errorMessagereplaces the default message only when the array is empty (required / minItems); other errors (e.g.maxItems) keep AJV's wording.arrayfixture usesminItems: 1andoptions.errorMessage.Release notes
Array fields now show a red
*when they are required or haveminItemsof at least 1, and show their validation error under the title. A new uiSchema optionerrorMessagereplaces the default message when the array is empty.Test plan
*and custom empty-array error after removing all items.