code-forge-io / code-forge-io/remix-hook-form
Incorrect serialization of zod objects with complex types (transform, refine,...)
- Dominant language
- TypeScript
- Stars
- 453
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I'm working with complex dates, because our app requires timezone dependent functionality.
So I have custom transformations like this one:
`startDate: z.string().transform(date => DateTime.fromFormat(date, 'yyyy-MM-dd')),`
### Expected scenario
startDate is serialized like: '2025-01-01'
### What actually happens
Transformation already runs on the client side and calls the toString() function of DateTime leading to a serialized string value of "2025-01-01T00:00:00+1"
Zod makes a distinction between input and output types, the transformation should only occur on the backend. React-hook-forms supports this like this: https://github.com/orgs/react-hook-form/discussions/8496#discussioncomment-8800129
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.