ITADN

fix: useField with object values now validates correctly (#5088)

#5142Pull Requestlogaretm 创建于 2026-03-04
L
logaretmcommented
## Summary - Fixes #5088: When using `useField` with object values and a schema that reports validation errors at nested sub-paths (e.g., yup reporting errors at `someObject.id` for a field registered as `someObject`), the errors were stored in `extraErrorsBag` and never cleaned up during subsequent validations. - This caused `form.meta.valid` to remain `false` even after `resetForm` with valid values, because stale nested-path errors persisted in the extra error bag. - Two fixes applied: 1. In the `validateSchema` callback, also clean up `extraErrorsBag` entries for the original error path when it gets hoisted to a parent field path. 2. In `resetForm`, clear `extraErrorsBag` before setting new errors to ensure stale nested-path errors don't persist across resets. ## Test plan - [x] Added regression test that uses yup schema with nested object validation, delayed field rendering via `v-if`, and `resetForm` with valid values - [x] Verified all existing tests pass (356 tests, 3 pre-existing unrelated failures in package resolution) - [x] Pre-commit hooks (lint, prettier, vitest) pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
合并状态:未合并 3 条评论