react-f0rm 0.11.1 → 1.0.0

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/dist/index.umd.js CHANGED
@@ -63,6 +63,16 @@
63
63
  const result = [];
64
64
  let identifier = "";
65
65
  const flushIdentifier = () => {
66
+ if (isIndex(identifier)) {
67
+ const dotted = [...result.map(String), identifier].join(".");
68
+ const bracket = result.reduce(
69
+ (acc, seg) => acc + (typeof seg === "number" ? `[${seg}]` : `${acc ? "." : ""}${seg}`),
70
+ ""
71
+ );
72
+ throw new TypeError(
73
+ `Numeric path segment must use bracket notation: "${dotted}" \u2192 "${bracket}[${identifier}]" (path: ${path})`
74
+ );
75
+ }
66
76
  result.push(identifier);
67
77
  identifier = "";
68
78
  };
@@ -614,7 +624,10 @@
614
624
  }
615
625
  function setFormErrors(form, result, segments = [], footprint) {
616
626
  Object.entries(result).forEach(([key, value]) => {
617
- const path = [...segments, ...normalizePath(key)];
627
+ const path = [
628
+ ...segments,
629
+ ...isIndex(key) ? [key] : normalizePath(key)
630
+ ];
618
631
  if (typeof value === "string") {
619
632
  if (value) {
620
633
  setError(form, path, value);