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
Is your feature request related to a problem? Please describe.
When you have a multiSelect/array field, by default an empty array will be assigned to the array field in the formData. If we try to submit a required empty multiSelect, the form will be submitted because AJV8 doesn't recognize it as empty and doesn't show validation errors. To avoid this behavior, we can currently set the emptyObjectFields to skipDefault, but this will skip all default values in the schema for example also for a string input that has default property.
Introduce a new option for emptyObjectFields. For example skipEmptyDefaults, which will not assign an empty array to an array/multiSelect field. It will still apply the default value if we have a default property present in your schema.
* Added skipEmptyDefaults feature
* Fixed an issue where the skipEmptyDefault option was not displaying default values for fields that are not required.
* Updated tests and the changelog
* Updated changelog: moved chakra-ui changes above utils.
---------
Co-authored-by: Abdallah Al-Soqatri <abdallah.al-soqatri@aspentech.com>
Prerequisites
What theme are you using?
core
Is your feature request related to a problem? Please describe.
When you have a multiSelect/array field, by default an empty array will be assigned to the array field in the formData. If we try to submit a required empty multiSelect, the form will be submitted because AJV8 doesn't recognize it as empty and doesn't show validation errors. To avoid this behavior, we can currently set the
emptyObjectFields
toskipDefault
, but this will skip all default values in the schema for example also for a string input that has default property.Demonstration of the issue:
The formData results from different options of
emptyObjectFields
(Demo link).Raw Validate
response: no AJV errors encountered.Raw Validate
response: no AJV errors encountered.Raw Validate
response:Describe the solution you'd like
Introduce a new option for
emptyObjectFields
. For exampleskipEmptyDefaults
, which will not assign an empty array to an array/multiSelect field. It will still apply the default value if we have a default property present in your schema.What do you think about this?
Describe alternatives you've considered
No response
The text was updated successfully, but these errors were encountered: