2022-06-10 00:32:34 +00:00
|
|
|
import { recurringEventType as recurringEventSchema } from "@calcom/prisma/zod-utils";
|
|
|
|
import type { RecurringEvent } from "@calcom/types/Calendar";
|
|
|
|
|
|
|
|
export function isRecurringEvent(obj: unknown): obj is RecurringEvent {
|
2023-03-10 22:10:56 +00:00
|
|
|
const parsed = recurringEventSchema.safeParse(obj);
|
|
|
|
|
|
|
|
return parsed.success;
|
2022-06-10 00:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function parseRecurringEvent(obj: unknown): RecurringEvent | null {
|
|
|
|
let recurringEvent: RecurringEvent | null = null;
|
2023-03-10 22:10:56 +00:00
|
|
|
|
2022-06-10 00:32:34 +00:00
|
|
|
if (isRecurringEvent(obj)) recurringEvent = obj;
|
2023-03-10 22:10:56 +00:00
|
|
|
|
2022-06-10 00:32:34 +00:00
|
|
|
return recurringEvent;
|
|
|
|
}
|