ITADN

fix: allow combining global and local validation rules (#5025)

#5146Pull Requestlogaretm 创建于 2026-03-04
L
logaretmcommented
## Summary Fixes #5025 - **Object syntax**: `{ required: true, myLocalRule: myValidatorFn }` now works by separating function-valued entries (inline validators) from string-keyed global rule references, running both - **Array syntax**: `['required', myValidatorFn]` now works by resolving string elements as global rules instead of calling them directly as functions - Added tests for both object and array syntax combining global and local rules ## Changes ### `packages/vee-validate/src/validate.ts` - In the array branch of `_validate`, string entries are now resolved via `normalizeRules` and `_test` (global rule lookup) instead of being called as functions - Added a new object-handling branch that separates function-valued entries from non-function entries, running global rules via `_test` and inline functions directly ### `packages/vee-validate/src/useField.ts` - When the rules object contains function values (inline validators mixed with global rules), it is passed through as-is to `_validate` instead of going through `normalizeRules` which would corrupt the function references ## Test plan - [x] Added test: global and local rules combined in object syntax - validates both rules run, both can fail independently - [x] Added test: global and local rules combined in array syntax - validates string rules are resolved globally and function rules run inline - [x] All 388 existing tests continue to pass (63 test files) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
合并状态:未合并 3 条评论