Closed sam-goodwin closed 1 year ago
Wasted way too much time looking into this: https://github.com/functionless/eventual/tree/sam/zod-effects
Got all the way and then realized Zod doesn't do serialization, so the user can't provide a way to convert Date (i.e. artbitrary type) into primitive. Fucking annoying.
We should allow users to use
.transform
in Zod to map serializable values into JavaScript-native types and objects.E.g. use an ISO string in DynamoDB but mapped to JS's Date at runtime
We are too strict with types:
Perhaps the
ZodEffects<ZodString, Date, string>
here - we can validate on thestring
instead of theDate
. We can directly see the serialized type is valid.