The next/server#NextRequest object to validate the query parameters for
The Zod schema to validate the query parameters against
The validated query parameters
import { validateQuery } from 'next-api-utils';
import { z } from 'zod';
export const GET = (request) => {
const query = validateQuery(request, z.object({ foo: z.string() }));
};
InvalidQueryParametersException Thrown if the query parameters failed validation
Validate the query parameters in a request with a Zod schema. Throws an exception if the query parameters do not match the schema. You can use ExceptionWrapper to automatically catch the exception and send it to the client.