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
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
-
I wonder if there is a smart way to replace this code, which always has to parse JSON before parsing it with zod:
I came up with this (following some SO post):
and then one can just write
const response = JsonSchema.parse(data)
but its still too complicated with the piping, imho.I would prefer something more along the lines:
if input is string transform to object first, then validate object
Or a helper function, which detects what to do?
Beta Was this translation helpful? Give feedback.
All reactions