I always get Expected date, received string issue in Zod.
This is my Schema ```ts
export const Schema = z.object({
// Other fields !
datePublished: z.string().pipe(z.coerce.date()),
});
I use this middleware to validate the request body ```ts
export const validateBody =
<T extends z.ZodType>(schema: T) =>
async (req: Request, res: Response, next: NextFunction) => {
try {
await schema.parseAsync(req.body);
next();
} catch (error: any) {
res.status(400).json({ error: error.issues });
}
};
What am I doing wrong here?