Dynamically create a zod schema based on a remote configuration #3111
Unanswered
SensoryDavide
asked this question in
Q&A
Replies: 2 comments
-
Stumbled onto this looking for the same thing. Curious if you ever found a more ideal solution. Thanks! I'm currently managing |
Beta Was this translation helpful? Give feedback.
0 replies
-
I am also having a similar issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there, I've been having more trouble than I thought creating form validation for a dynamic form using zod. The form lives on multiple domains and depending on the domain, a different configuration is fetched from a remote server. It might look like this:
Based on the enabled property, I want to expand the schema. Initially I thought something like this might work:
However, the typing for scheme remains the base scheme
The other way around results in the same type
It seems like either zod or TypeScript can't infer the conditional type from .merge because as soon as I assign it to a new variable, it works:
Any ideas how I could keep the typesafety? My current approach that kind of works looks like this:
Which is obviously not ideal and error-prone as you have to manually update the FinalFormType
Beta Was this translation helpful? Give feedback.
All reactions