Haddok - hi , i have defined a schema where i a...
hi , i have defined a schema where i am accessing a few fields using shape for some specific scenario
i tried using
myschema.shape[fieldname].safeparse(value)
this throws error that
myschema.shape[fieldname] is undefined
is there any way to access shapes with passed value ?
for context myschema.shape.name.safeparse(value) works fine, i just want to create a generic function for different fields of the form
2 Replies
With an error, I assume you mean a Typescript one?
Cause yea you’ll have to type these as being a key off shape and possibly do some casting
Are you trying to do something like: