apolodoro
apolodoro
Explore posts from servers
HHono
Created by apolodoro on 7/15/2024 in #help
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>>'.
1 replies