d81d772cdf
* 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>
14 lines
443 B
TypeScript
14 lines
443 B
TypeScript
import { intervalLimitsType } from "@calcom/prisma/zod-utils";
|
|
import type { IntervalLimit } from "@calcom/types/Calendar";
|
|
|
|
export function isBookingLimit(obj: unknown): obj is IntervalLimit {
|
|
return intervalLimitsType.safeParse(obj).success;
|
|
}
|
|
|
|
export function parseBookingLimit(obj: unknown): IntervalLimit | null {
|
|
let bookingLimit: IntervalLimit | null = null;
|
|
if (isBookingLimit(obj)) bookingLimit = obj;
|
|
|
|
return bookingLimit;
|
|
}
|