Skip to content

Yup resolver returns a promise in synchronous mode #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
metalmarker opened this issue May 8, 2023 · 0 comments
Open

Yup resolver returns a promise in synchronous mode #556

metalmarker opened this issue May 8, 2023 · 0 comments

Comments

@metalmarker
Copy link

metalmarker commented May 8, 2023

Is your feature request related to a problem? Please describe.
I'm using yupResolver in synchronous mode. The problem I'm facing is that although the schema is correctly invoked via yup's validateSync, yupResolver still returns a promise.

That's not a problem when yupResolver is invoked directly via useHook's resolve (because it uses await on resolve), but it does become a problem when running yupResolve outside of the form context, because I need to use async/await on the entire execution chain of leading up to yupResolve.

Why am I using yupResolve outside of the form? Because I'm validating the form data before displaying the form, and I'm trying to use the same higher-level validation method that is based on yupResolve.

Describe the solution you'd like
It would be great if yupResolver would return a regular (resolved) result instead of a promise when called with mode='sync' to support a use case where yupResolver is executed synchronously also outside of useForm().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants