2022-06-15 22:18:40 +00:00
|
|
|
import { withValidation } from "next-validations";
|
|
|
|
import { z } from "zod";
|
|
|
|
|
2022-10-11 20:14:03 +00:00
|
|
|
import { stringOrNumber } from "@calcom/prisma/zod-utils";
|
|
|
|
|
2022-06-15 22:18:40 +00:00
|
|
|
import { baseApiParams } from "./baseApiParams";
|
|
|
|
|
|
|
|
// Extracted out as utility function so can be reused
|
|
|
|
// at different endpoints that require this validation.
|
2022-12-05 23:09:19 +00:00
|
|
|
export const schemaQueryUserId = baseApiParams.extend({
|
|
|
|
userId: stringOrNumber,
|
|
|
|
});
|
2022-10-11 20:14:03 +00:00
|
|
|
|
|
|
|
export const schemaQuerySingleOrMultipleUserIds = z.object({
|
|
|
|
userId: z.union([stringOrNumber, z.array(stringOrNumber)]),
|
|
|
|
});
|
|
|
|
|
2022-10-21 19:54:28 +00:00
|
|
|
export const schemaQuerySingleOrMultipleTeamIds = z.object({
|
|
|
|
teamId: z.union([stringOrNumber, z.array(stringOrNumber)]),
|
|
|
|
});
|
|
|
|
|
2022-06-23 22:09:23 +00:00
|
|
|
export const withValidQueryUserId = withValidation({
|
|
|
|
schema: schemaQueryUserId,
|
|
|
|
type: "Zod",
|
|
|
|
mode: "query",
|
|
|
|
});
|