Skip to content

fix: normalize standard schema error paths to bracket notation#5131

Open
logaretm wants to merge 1 commit intomainfrom
fix/5108-standard-schema-paths
Open

fix: normalize standard schema error paths to bracket notation#5131
logaretm wants to merge 1 commit intomainfrom
fix/5108-standard-schema-paths

Conversation

@logaretm
Copy link
Owner

@logaretm logaretm commented Mar 4, 2026

Summary

Fixes #5108

  • When standard schema validation (e.g., Zod) returns errors for array fields, the error paths use dot notation (e.g., items.0.name). However, vee-validate internally uses bracket notation (e.g., items[0].name) when registering fields via useField/useFieldArray.
  • This mismatch causes validation errors to not be mapped to the correct fields, particularly when multiple fields trigger validation concurrently and the withLatest deduplication skips the onDone path normalization for earlier callers.
  • The fix applies normalizeFormPath() to error paths inside validateStandardSchema(), ensuring paths are consistently in bracket notation regardless of the withLatest execution path.

Changes

  • packages/vee-validate/src/validate.ts: Import normalizeFormPath from shared utilities and apply it to error.path in validateStandardSchema() 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

  • New test: single-level array paths are normalized from items.0.name to items[0].name
  • New test: nested array paths are normalized from groups.0.members.0.email to groups[0].members[0].email
  • New test: non-array dot paths (e.g., user.name) remain unchanged
  • All existing tests pass (33/34 test files; the 1 failure in validate.spec.ts is a pre-existing environment issue unrelated to this change)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 4, 2026 06:35
@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest 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

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for vee-validate-v5 ready!

Name Link
🔨 Latest commit 140c776
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-v5/deploys/69a7d2d036ffe40008a4f56b
😎 Deploy Preview https://deploy-preview-5131--vee-validate-v5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for vee-validate-docs canceled.

Name Link
🔨 Latest commit 140c776
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-docs/deploys/69a7d2d0791450000884ff14

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.path with normalizeFormPath() inside validateStandardSchema() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v5: validateStandardSchema - inconsistent dot notation VS bracket notation in error.path

2 participants