The NextRouteHandlerSegmentData object to validate the path parameters for
The Zod schema to validate the path parameters against
The validated path parameters
import { validateParams } from 'next-api-utils';
import { z } from 'zod';
export const GET = (request, segmentData) => {
const params = validateParams(segmentData, z.object({ foo: z.string() }));
};
InvalidPathParametersException Thrown if the path parameters failed validation
Validate the path 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.