tRPCttRPC
Powered by
sh03S
tRPC•16mo ago•
3 replies
sh03

Custom data transformer

Has anyone had any experience with custom data transformers? I'm trying to map
LocalDate
LocalDate
,
LocalTime
LocalTime
,
Instant
Instant
, etc. from a date & time library. Every type can be serialized to a string (the corresponding ISO format) but it's unclear to me what the best strategy is via a data transformer?

Should I serialize these objects to a custom shape (e.g.
{ type: "LocalDate", value: "..." }
{ type: "LocalDate", value: "..." }
) so that it's trivial to deserialize? Seems kinda redundant since the
type
type
information is already at the type level. Without a custom shape it's unclear to me how I would be able to deserialize the object given that I don't know the destination type.
Solution
It worked just fine as described above. 👍
Jump to solution
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Custom data transformer and input/output schema
Titouan Créac'hTTitouan Créac'h / ❓-help
2y ago
Using superjson transformer makes data empty
MartinMMartin / ❓-help
17mo ago
How to obfuscate data via transformer
douDdou / ❓-help
3y ago