resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

Yup resolver returns a promise in synchronous mode

Open metalmarker opened this issue 2 years ago • 0 comments

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().

metalmarker avatar May 08 '23 16:05 metalmarker