H
Hono5mo ago
apolodoro

zValidator Middleware Error

I have literally only implemented the example
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";

const app = new Hono();

const route = app.post(
"/posts",
zValidator(
"form",
z.object({
body: z.string(),
})
),
(c) => {
const validated = c.req.valid("form");
// ... use your validated data
}
);
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";

const app = new Hono();

const route = app.post(
"/posts",
zValidator(
"form",
z.object({
body: z.string(),
})
),
(c) => {
const validated = c.req.valid("form");
// ... use your validated data
}
);
And is giving me this typescript error
Argument of type 'MiddlewareHandler<Env, string, { in: { form: { body: string | File; }; }; out: { form: { body: string; }; }; }>' is not assignable to parameter of type 'H<BlankEnv, "/posts", BlankInput, HandlerResponse<any>>'.
Argument of type 'MiddlewareHandler<Env, string, { in: { form: { body: string | File; }; }; out: { form: { body: string; }; }; }>' is not assignable to parameter of type 'H<BlankEnv, "/posts", BlankInput, HandlerResponse<any>>'.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server