react-jsonschema-form
react-jsonschema-form copied to clipboard
Cannot default array of objects to an empty array
Prerequisites
- [x] I have read the documentation;
- [x] In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.
Description
When creating an array of objects using minItems there is no way to default the array to an emtpy array. If the array is empty the package with fill it with the structure of the object with all of its keys having values of undefined.
Steps to Reproduce
Expected behavior
When an array of objects has a default value of [] and minItems set higher than 1 it should default to an empty array with a validation error saying that the array must have at least minItems.
Actual behavior
minItems number of empty objects are injected into the array to satisfy the minItems constraint. If the object has any required fields validation with throw an error about the empty object not having that field instead of the array not having enough items.
Version
1.0.4
I think the underlying problem here is actually that the defaults weren't being applied to form correctly. The PR #1034 which was merged yesterday fixes this (you can test by checking out master and running the playground locally).
edit: just tried this running master and see this:

@glasserc when do you think 1.0.5 will be pushed to NPM?
I can probably cut a release today. I am trying to figure out how to handle #991.
I am still getting the same issue on master 😞