Skip to content

Yup resolver returns a promise in synchronous mode #556

Open
@metalmarker

Description

@metalmarker

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions