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
I have two checkboxes in a form, either can be optional but one must be selected to proceed. I'm not sure how to make it work though. My original schema is below
options: z.object({health: z.optional(z.string({required_error: 'A health package is required'}).min(1,'A health package is required').transform(val=>val==='on')),retirement: z.optional(z.string().min(1,'A retirement package is required').transform(val=>val==='on'),),}),
I have also tried this, nut with no success
options: z.union([z.object({health: z.string({required_error: 'A health package is required'}).min(1,'A health package is required').transform(val=>val==='on'),retirement: z.string({required_error: 'A retirement package is required'}).min(1,'A retirement package is required').transform(val=>val==='on'),}).strict(),// .strict is needed for your use case to work properlyz.object({health: z.string({required_error: 'A health package is required'}).min(1,'A health package is required').transform(val=>val==='on'),}).strict(),// .strict is needed for your use case to work properlyz.object({retirement: z.string({required_error: 'A retirement package is required'}).min(1,'A retirement package is required').transform(val=>val==='on'),}).strict(),// .strict is needed for your use case to work properly]),
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I have two checkboxes in a form, either can be optional but one must be selected to proceed. I'm not sure how to make it work though. My original schema is below
I have also tried this, nut with no success
Beta Was this translation helpful? Give feedback.
All reactions