Passing function as `zValidator` Middleware (accessing `c`)
movahhedi opened this issue · comments
Shahab Movahhedi commented
I found the need to access the context object (c
) in defining my zValidator
.
Like this:
// ...
.post(
"/login/otp",
zValidator("json"
z.object({
otp: z.string().length(c.env.otpLength),
}),
),
// ...
I suggest supporting passing a function as the 2nd parameter of zValidator
with a signature of somehting like (c: Context) => zValidatorType
. Like this:
// ...
.post(
"/login/otp",
zValidator("json"
+ (c) =>
z.object({
otp: z.string().length(c.env.otpLength),
}),
),
// ...