Open Schniz opened 2 years ago
This can also be handy for stuff like passing Date
objects, if the parser is symmetric (Parser<From, To> = { parse(from: From): To, encode(to: To): From }
), but Zod unfortunately does not support that syntax AFAIK (while io-ts
does)
The idea behind this feature is to enable long-running clients to react to changes in the backend schemas. Imagine you have an endpoint that returns
{ version: 1, data: string }
and then while the customer is on your app, the server redeploys and now it returns{ version: 2, result: string }
. You probably want to make a hard-refresh, or at least show an error.The suggested API would be something like: