So I'm working on a complex form, one of the parts is that it has this "type" section. Now based on the type, it will have different fields. So if
type === "foo"
type === "foo"
then fields
A
A
and
B
B
are shown, and are required. However if
type === "bar"
type === "bar"
then Field C is required.
Whats the best way to handle this for the form? I'm using zod and while I want to reach for a discriminated union, and it seems to work on runtime, but my problem is when using form.Subscribe the
{values}
{values}
does not contain any of those discriminated fields.
I see my option could be to make them optional fields and then make them not-optional via refine/superRefine, but that seems suboptimal