Skip to content

Commit

Permalink
fix: re-apply form errors on fields to avoid race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Mar 8, 2024
1 parent cdf0a80 commit 07d01fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-tools-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vee-validate": patch
---

fix: re-apply errors to avoid race conditions
17 changes: 17 additions & 0 deletions packages/vee-validate/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,23 @@ export function useForm<
results.values = formResult.values;
}

keysOf(results.results).forEach(path => {
const pathState = findPathState(path);
if (!pathState) {
return;
}

if (mode === 'silent') {
return;
}

if (mode === 'validated-only' && !pathState.validated) {
return;
}

setFieldError(pathState, results.results[path]?.errors);
});

return results;
},
);
Expand Down

0 comments on commit 07d01fd

Please sign in to comment.