You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm managing a global state that keeps the form values of multiple forms (each with React Hook Form),
To validate all forms at once, I have to subscribe each form's 'trigger' function to an array, and execute all on click "Save"/"Update".
Since I don't have a reason to use asynchronous validation I use yupResolver(filtersSchema, undefined, { mode: 'sync' }) for synchronous validation. But the trigger function always returns a Promise.
This makes it a bit weird in the code (using Tanstack Query):
Is your feature request related to a problem? Please describe.
I'm managing a global state that keeps the form values of multiple forms (each with React Hook Form),
To validate all forms at once, I have to subscribe each form's 'trigger' function to an array, and execute all on click "Save"/"Update".
Since I don't have a reason to use asynchronous validation I use
yupResolver(filtersSchema, undefined, { mode: 'sync' })
for synchronous validation. But thetrigger
function always returns a Promise.This makes it a bit weird in the code (using Tanstack Query):
It's weird since I need to
await
forvalidateForm
function but this shouldn't really be async.Describe the solution you'd like
When
{ mode: 'sync' }
is specified,trigger
function should return a boolean (whether form is valid).Describe alternatives you've considered
This solution suggested by @bluebill1049, but I haven't tried if it works sychronously.
#88 (comment)
The text was updated successfully, but these errors were encountered: