UNPKG

next-validations

Version:

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

13 lines (10 loc) 698 B
import { Schema } from '@typeschema/main'; import { NextApiRequest, NextApiResponse } from 'next'; type NextHandler = (err?: Error) => void; type ValidationHoF = { mode?: 'body' | 'query' | 'headers'; schema: Schema; }; declare function withValidation({ schema, mode }: ValidationHoF): (handler?: (req: NextApiRequest, res: NextApiResponse) => any) => (req: NextApiRequest, res: NextApiResponse, next?: NextHandler) => Promise<any>; declare function withValidations(validations: ValidationHoF[]): (handler?: (req: NextApiRequest, res: NextApiResponse) => any) => (req: NextApiRequest, res: NextApiResponse, next?: NextHandler) => Promise<any>; export { withValidation, withValidations };