Support asynchronous parsing
mdoury opened this issue · 1 comments
zod
exports the parseAsync
and safeParseAsync
methods to handle asynchronous refinements and transforms.
If you use asynchronous refinements or transforms (more on those later), you'll need to use
.parseAsync
It'd be great it zodix
could support those to improve the overall compatibility with zod
.
I'm not sure which way to go, I see two solutions to this problem:
- make all parsing functions asynchronous by default
- add asynchronous methods to the package, i.e.
parseParamsAsync
,parseParamsSafeAsync
,parseQueryAsync
, andparseQuerySafeAsync
?
In zod
, parseAsync
and safeParseAsync
methods handle both synchronous and asynchronous cases.
In my opinion the first solution is better as it does not increase the number of methods in zodix
, making it harder to use and to maintain.
Additionally, zx.parseForm
and zx.parseFormSafe
are already asynchronous so this would make the use of zodix
parsing methods more homogenous.
However this would introduce breaking changes... It's probably better to introduce them now than later but it's still annoying.
@rileytomasek Do you know of any use cases where the user is not able to call an async
function? The only one I can think of is during render, but zodix
should probably not be used during render anyway.