fix: normalize standard schema error paths to bracket notation#5131
fix: normalize standard schema error paths to bracket notation#5131
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 140c776 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for vee-validate-v5 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for vee-validate-docs canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes inconsistent error-path formatting from Standard Schema validators (e.g., Zod) by normalizing array index segments to vee-validate’s bracket notation, ensuring schema validation errors map reliably onto registered fields (Fixes #5108).
Changes:
- Normalize
error.pathwithnormalizeFormPath()insidevalidateStandardSchema()before using it as a results/errors map key. - Add a dedicated test suite covering single-level arrays, nested arrays, and non-array dot paths.
- Add a patch changeset documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/vee-validate/src/validate.ts | Normalizes standard schema issue paths to bracket notation before storing results/errors. |
| packages/vee-validate/tests/validateStandardSchema.spec.ts | Adds tests asserting correct bracket-notation mapping for array paths (including nested arrays). |
| .changeset/fix-5108-standard-schema-paths.md | Adds a patch changeset entry describing the normalization fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes #5108
items.0.name). However, vee-validate internally uses bracket notation (e.g.,items[0].name) when registering fields viauseField/useFieldArray.withLatestdeduplication skips theonDonepath normalization for earlier callers.normalizeFormPath()to error paths insidevalidateStandardSchema(), ensuring paths are consistently in bracket notation regardless of thewithLatestexecution path.Changes
packages/vee-validate/src/validate.ts: ImportnormalizeFormPathfrom shared utilities and apply it toerror.pathinvalidateStandardSchema()before using it as a key in results/errors maps.packages/vee-validate/tests/validateStandardSchema.spec.ts: New test file with 3 tests verifying bracket notation normalization for single-level arrays, nested arrays, and non-array dot paths..changeset/fix-5108-standard-schema-paths.md: Patch changeset for vee-validate.Test plan
items.0.nametoitems[0].namegroups.0.members.0.emailtogroups[0].members[0].emailuser.name) remain unchangedvalidate.spec.tsis a pre-existing environment issue unrelated to this change)🤖 Generated with Claude Code