remix-validated-form 4.6.3 → 4.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remix-validated-form",
3
- "version": "4.6.3",
3
+ "version": "4.6.4",
4
4
  "description": "Form component and utils for easy form validation in remix",
5
5
  "browser": "./dist/remix-validated-form.cjs.js",
6
6
  "main": "./dist/remix-validated-form.umd.js",
@@ -105,7 +105,9 @@ export const mutateAsArray = (
105
105
  const newKeys = getDeepArrayPaths(arr);
106
106
  for (const key of newKeys) {
107
107
  const val = getPath(arr, key);
108
- obj[`${field}${key}`] = val;
108
+ if (val !== undefined) {
109
+ obj[`${field}${key}`] = val;
110
+ }
109
111
  }
110
112
  };
111
113
 
@@ -354,6 +356,19 @@ if (import.meta.vitest) {
354
356
  });
355
357
  });
356
358
 
359
+ it("should not create keys for `undefined`", () => {
360
+ const values = {
361
+ "myField[0]": "foo",
362
+ };
363
+ mutateAsArray("myField", values, (arr) => {
364
+ arr.unshift(undefined);
365
+ });
366
+ expect(Object.keys(values)).toHaveLength(1);
367
+ expect(values).toEqual({
368
+ "myField[1]": "foo",
369
+ });
370
+ });
371
+
357
372
  it("should handle remove", () => {
358
373
  const values = {
359
374
  myField: "something",