Skip to content

Commit 625f797

Browse files
logaretmclaude
andcommitted
fix: useField validated-only mode for arrays (#5029)
Fix useField.validate() to properly handle 'validated-only' mode by checking the field's validated flag. Previously, validated-only mode was treated the same as force mode in useField, causing unintended side effects when useFieldArray triggered form-wide validation after mutations. Now, fields that haven't been interacted with yet will only get their valid flag updated (silent validation) without incorrectly marking them as validated or setting error messages prematurely. Also adds comprehensive test coverage for useFieldArray with object items including schema validation, meta updates (valid/dirty), nested property mutations via computedDeep, and interaction with useField. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7d8cc52 commit 625f797

3 files changed

Lines changed: 660 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"vee-validate": patch
3+
---
4+
5+
Fix useFieldArray schema validation and meta updates for object items (#5029)

packages/vee-validate/src/useField.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ function _useField<TValue = unknown>(
207207
return validateValidStateOnly();
208208
}
209209

210+
// In validated-only mode, only validate fields that have been previously validated
211+
// This prevents showing errors on fields the user hasn't interacted with yet (#5029)
212+
if (opts?.mode === 'validated-only' && !meta.validated) {
213+
return validateValidStateOnly();
214+
}
215+
210216
return validateWithStateMutation();
211217
}
212218

0 commit comments

Comments
 (0)