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
We currently have two separate Form-components which are wrapping the useForm hook with various common setup and other stuff. One uses Zod and the other uses Yup. Now that both support the new'ish Standard Schema spec I'd really want to merge these two since they're basically the exact same, just with different resolvers and types.
This went fine until I realized the YupForm variant also has the Context thing which seems to be passed to the Yup resolver behind the scenes by react-hook-form. When I switch over to the standardSchemaResolver the context is (understandably, I suppose), no longer passed to the Yup schemas during validation...
Any suggestions on how to resolve this?
A "workaround" that seems to work is to create my own "wrapper resolver", but not sure if that's the best way, but maybe it is? One issue is of course that you can still pass a context to the component which will be completely ignored unless the schema is a Yup schema, but I suppose that's how useForm work anyways?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We currently have two separate Form-components which are wrapping the
useFormhook with various common setup and other stuff. One uses Zod and the other uses Yup. Now that both support the new'ish Standard Schema spec I'd really want to merge these two since they're basically the exact same, just with different resolvers and types.This went fine until I realized the YupForm variant also has the Context thing which seems to be passed to the Yup resolver behind the scenes by
react-hook-form. When I switch over to thestandardSchemaResolverthe context is (understandably, I suppose), no longer passed to the Yup schemas during validation...Any suggestions on how to resolve this?
A "workaround" that seems to work is to create my own "wrapper resolver", but not sure if that's the best way, but maybe it is? One issue is of course that you can still pass a context to the component which will be completely ignored unless the schema is a Yup schema, but I suppose that's how
useFormwork anyways?Beta Was this translation helpful? Give feedback.
All reactions