cal/packages/lib/isRecurringEvent.ts
Lucas Smith d81d772cdf
feat(lib): add more tests to lib package (#7210)
* feat(lib): add more tests to lib package

Add more tests to the lib package to make it more robust overall. Additionally, tidy any methods that can be modified without changing behaviour and tighten types where possible.

* fix(lib): update missed imports

* fix: revert stylistic changes

* Update getSchedule.test.ts

---------

Co-authored-by: Omar López <zomars@me.com>
2023-03-10 22:10:56 +00:00

17 lines
512 B
TypeScript

import { recurringEventType as recurringEventSchema } from "@calcom/prisma/zod-utils";
import type { RecurringEvent } from "@calcom/types/Calendar";
export function isRecurringEvent(obj: unknown): obj is RecurringEvent {
const parsed = recurringEventSchema.safeParse(obj);
return parsed.success;
}
export function parseRecurringEvent(obj: unknown): RecurringEvent | null {
let recurringEvent: RecurringEvent | null = null;
if (isRecurringEvent(obj)) recurringEvent = obj;
return recurringEvent;
}