UNPKG

@overture-stack/lyric

Version:
14 lines (13 loc) 636 B
import { RequestHandler } from 'express-serve-static-core'; import { ZodSchema } from 'zod'; export declare type RequestValidation<TBody, TQuery, TParams> = { body?: ZodSchema<TBody>; query?: ZodSchema<TQuery>; pathParams?: ZodSchema<TParams>; }; /** * Validate the body using Zod parse * @param schema Zod objects used to validate request * @returns Throws a Bad Request when validation fails */ export declare function validateRequest<TBody, TQuery, TParams>(schema: RequestValidation<TBody, TQuery, TParams>, handler: RequestHandler<TParams, unknown, TBody, TQuery>): RequestHandler<TParams, unknown, TBody, TQuery>;