You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Skip populate function proposal in Experimental_ArrayMinItems (#4121)
* skip populate draft
* Added a new `computeSkipPopulate` option in `arrayMinItems`, allowing custom logic to skip populating arrays with default values
* Add example in documentation of computeSkipPopulate
* Update packages/docs/docs/api-reference/form-props.md
Co-authored-by: Heath C <[email protected]>
* Update packages/utils/src/types.ts
Co-authored-by: Heath C <[email protected]>
* Update packages/docs/docs/api-reference/form-props.md
Co-authored-by: Heath C <[email protected]>
---------
Co-authored-by: Marek Bodinger <[email protected]>
Co-authored-by: Heath C <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ should change the heading of the (upcoming) version to include a major version b
25
25
## @rjsf/utils
26
26
27
27
- Added a new `skipEmptyDefault` option in `emptyObjectFields`, fixing [#3880](https://github.com/rjsf-team/react-jsonschema-form/issues/3880)
28
+
- Added a new `computeSkipPopulate` option in `arrayMinItems`, allowing custom logic to skip populating arrays with default values, implementing [#4121](https://github.com/rjsf-team/react-jsonschema-form/pull/4121).
28
29
- Fixed bug where the string `"\</strong>"` would get printed next to filenames when uploading files, and restored intended bolding of filenames fixing [#4120](https://github.com/rjsf-team/react-jsonschema-form/issues/4120).
Copy file name to clipboardExpand all lines: packages/docs/docs/api-reference/form-props.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,70 @@ Optional enumerated flag controlling how array minItems are populated, defaultin
84
84
|`requiredOnly`| Ignore `minItems` on a field when calculating defaults unless the field is required. |
85
85
|`never`| Ignore `minItems` on a field when calculating defaults for required and non-required. Value will set only if defined `default` and from `formData`|
86
86
87
+
#### `arrayMinItems.computeSkipPopulate`
88
+
89
+
The signature and documentation for this property is as follow:
90
+
91
+
##### computeSkipPopulate <T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>()
92
+
93
+
A function that determines whether to skip populating the array with default values based on the provided validator, schema, and root schema.
94
+
If the function returns `true`, the array will not be populated with default values.
95
+
If the function returns `false`, the array will be populated with default values according to the `populate` option.
96
+
97
+
###### Parameters
98
+
99
+
- validator: ValidatorType<T, S, F> - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions
100
+
- schema: S - The schema for which resolving a condition is desired
101
+
-[rootSchema]: S - The root schema that will be forwarded to all the APIs
102
+
103
+
###### Returns
104
+
105
+
- boolean: A boolean indicating whether to skip populating the array with default values.
0 commit comments