cal.pub0.org/apps/api/lib/validations/shared/queryIdString.ts

20 lines
501 B
TypeScript
Raw Permalink Normal View History

import { withValidation } from "next-validations";
import { z } from "zod";
2022-03-30 12:17:55 +00:00
import { baseApiParams } from "./baseApiParams";
// Extracted out as utility function so can be reused
// at different endpoints that require this validation.
2022-10-19 18:26:12 +00:00
/** Used for UUID style id queries */
2022-03-30 12:17:55 +00:00
export const schemaQueryIdAsString = baseApiParams
.extend({
id: z.string(),
})
.strict();
2022-03-30 12:17:55 +00:00
export const withValidQueryIdString = withValidation({
schema: schemaQueryIdAsString,
type: "Zod",
mode: "query",
});