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

19 lines
463 B
TypeScript
Raw 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-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",
});