react-hook-form / resolvers

📋 Validation resolvers: Yup, Zod, Superstruct, Joi, Vest, Class Validator, io-ts, Nope, computed-types, typanion, Ajv, TypeBox, ArkType, Valibot, effect-ts and VineJS
https://react-hook-form.com/
MIT License
1.77k stars 161 forks source link

Yup Lazy schema is not accepted as revolver parameter #567

Closed Mrowa96 closed 1 year ago

Mrowa96 commented 1 year ago

Describe the bug When passing yup.Lazy object as a parameter to yupResolver it gives us error that we are not passing expected type as a parameter.

To Reproduce Please check code sandbox, it's a type error not runtime one.

Codesandbox link (Required) https://codesandbox.io/s/weathered-snowflake-wj71vi?file=/src/logic.ts

Expected behavior Passing yup.Lazy should not generate any type issues.

Screenshots

image
10may commented 1 year ago

I'm also facing this issue, is there any update or workaround?

HenryVogt commented 1 year ago

I'm also running in to this. In my case, I have a schema that is concatinated with another one under certain condition. I use 'lazy' to wrap this conditional logic. When I pass the lazy schema into the resolver, conditional validation works as intendent but Typescript is complaining like @Mrowa96 mentioned.

Codesandbox example https://codesandbox.io/p/sandbox/yupresolver-lazy-inference-nrmgz6

jorisre commented 1 year ago

Released in 3.3.0