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
This proposal proposes an alternative to the AutoForm.dependencies api.
Why
I believe the AutoForm dependencies API should be part of the schema itself. Otherwise we get a typical split brain problem, where one information is stored in multiple places.
From my point of view the DependencyType API is not needed, since we can replace these by z.DiscriminatedUnion and:
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
-
This proposal proposes an alternative to the AutoForm.dependencies api.
Why
I believe the AutoForm dependencies API should be part of the schema itself. Otherwise we get a typical split brain problem, where one information is stored in multiple places.
From my point of view the DependencyType API is not needed, since we can replace these by
z.DiscriminatedUnion
and:z.never()
DependencyType.HIDES
!z.optional()
DependencyType.REQUIRES
!z.enum()
DependencyType.SETS_OPTIONS
Example
This increases the usability of zod and makes our AutoForms more declarative.
Code (Proof of Concept)
To add discriminatedUnion to your Auto Form check out the following commit: HaNdTriX/vue-auto-form-discriminated-union@6f346b5
Resources
Feedback
I would love to get some early Feedback on this Idea. What do you think?
Beta Was this translation helpful? Give feedback.
All reactions