Repository navigation
fix(helpers): convert every array index in error paths; escape wildcard prefix - #60
Merged
Merged
Conversation
hugomallet
commented
Aug 6, 2026
hugomallet
left a comment
Collaborator
Author
There was a problem hiding this comment.
Tooled self-review (review53 skill) — PR authored by this account, so GitHub refuses an APPROVE; posting as COMMENT. Verdict: mergeable.
Verified
formatErrorsgflag: correct. Multi-digit indices (a[12].b[345]→a.12.b.345) and mixed paths convert properly; the[0-9]+class leaves AJV's quoted-key notation (['weird-key']) untouched.- Wildcard prefix escaping: the escape set is the standard MDN one and handles
[,(,+,\correctly (checked by direct evaluation). Bonus not stated in the PR description: the old code threwSyntaxError: Unterminated character classfor a prefix containing an unbalanced[(e.g.items[0.*) — the escape fixes that latent crash too. - Both call sites in
src/lib/Form/Form.js(errors + touchedFields filtering) are consistent with the new behavior; scope is strictlyhelpers.js+helpers.test.jsas announced. - New tests bite (fail on master), full suite green: 6 suites, 65 tests. Lint: the 6
jest/no-test-callbackerrors inhelpers.test.jsare pre-existing (untouchedgetFieldValueblocks), not introduced here.
Minor (grouped, non-blocking)
- The new wildcard test only exercises
.; one extra case with a[prefix (e.g.items[0].*) would lock in the SyntaxError fix above, which is currently untested. - Consumers who worked around bug 1 by writing bracket paths in
<FieldError name>(e.g.items.0.tags[1]) will see those stop matching — intentional, but worth a line in the changelog; same for the SyntaxError fix.
…rd prefix - formatErrors: the bracket-to-dot replace lacked the g flag, so only the first array index was converted (items[0].tags[1] -> items.0.tags[1]), breaking FieldError matching on deeply indexed paths. - filterByFieldNameWithWildcard: the wildcard prefix was injected raw into a RegExp, so the dot in 'user.*' matched any character and 'userX' was wrongly included. Both fixes are covered by new unit tests.
…card prefixes Before escaping, a wildcard like 'items[0*' compiled to /^items[0/ and threw 'SyntaxError: Unterminated character class'. The escaping fix also resolves this crash; this test locks it in.
hugomallet
force-pushed
the
fix/helpers-paths-wildcard
branch
from
August 6, 2026 13:13
efcd643 to
6f25159
Compare
24 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Observable defects
.replace(/\[([0-9]+)\]/, '.$1')lacked thegflag, so only the first array index was converted — an AJV error onitems[0].tags[1]producedfield = "items.0.tags[1]", and<FieldError name="items.0.tags.1">never matched.new RegExp— the dot inuser.*matched any character, souserXwas wrongly matched. A prefix with an unclosed bracket (e.g.items[0*) even threwSyntaxError: Unterminated character class.Fix
gflag to the index-conversion replace.Tests
items[0].tags[1]formats toitems.0.tags.1(fails on master withitems.0.tags[1]).user.*matchesuser.emailbut notuserX(fails on master withuserXincluded).items[0*filters without crashing (fails on master withSyntaxError: Unterminated character class).CI=true yarn test:runtime: 6 suites, 66 tests (63 before + 3 new), 5 snapshots — all green.Heads-up for consumers
If you worked around the old bug by writing bracket-notation paths in
<FieldError name>(e.g.name="items.0.tags[1]"), those names will no longer match: error paths are now fully dot-normalized (items.0.tags.1).