import type { Request, Response } from "express"; import type { ZodType } from "zod"; /** * Validates a part of an Express request using a Zod schema and returns the validated data. * * @param schema - The Zod schema to validate against * @param req - The Express request object * @param part - The part of the request to validate ("body", "query", "params", etc.) * @param res - The Express response object * @returns The validated data if successful, undefined if validation fails (and sends 400 response) * * @example * ```typescript * const bodySchema = z.object({ name: z.string() }); * * app.post("/api", (req, res) => { * const body = validateRequest(bodySchema, req, "body", res); * if (!body) return; * // body is now typed as { name: string } * console.log(body.name); * }); * ``` */ export declare function validateRequest(schema: ZodType, req: Request, part: keyof Request, res: Response): T | undefined;