Skip to content

Commit 07d01fd

Browse files
committed
fix: re-apply form errors on fields to avoid race conditions
1 parent cdf0a80 commit 07d01fd

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.changeset/chatty-tools-travel.md

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: re-apply errors to avoid race conditions

packages/vee-validate/src/useForm.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,23 @@ export function useForm<
436436
results.values = formResult.values;
437437
}
438438

439+
keysOf(results.results).forEach(path => {
440+
const pathState = findPathState(path);
441+
if (!pathState) {
442+
return;
443+
}
444+
445+
if (mode === 'silent') {
446+
return;
447+
}
448+
449+
if (mode === 'validated-only' && !pathState.validated) {
450+
return;
451+
}
452+
453+
setFieldError(pathState, results.results[path]?.errors);
454+
});
455+
439456
return results;
440457
},
441458
);

0 commit comments

Comments
 (0)