How to Resolve "Argument of type MiddlewareHandler Error"

The lines of code where I used zValidator throws the error "Argument of type MiddlewareHandler Error". Here is the code snippet of how I am using the validator.

jobRouter .route("/") .post( zValidator("json", JobSchema, (result, c) => { if (!result.success) { return c.json({ error: result.error.issues }, StatusCodes.BAD_REQUEST); } }), httpCreateJob )

Here is the Jobschema definition

export const JobSchema = z.object({ position: z.string().min(1, {message: "Position is required"}).max(50), company: z.string().min(1, {message:"Company is required"}).max(50), jobStatus: z.enum([jobStatus.interview, jobStatus.declined, jobStatus.pending]).optional(), jobType: z.enum([jobType.fullTime, jobType.internship, jobType.partTime, jobType.remote]).optional(), jobLocation: z.string().min(1, "Job location is required").optional(), })

While this is not breaking my code, I don't like the red lines on my screen and would appreciate any help to resolve this.
Was this page helpful?