cal/packages/lib/validateIntervalLimitOrder.ts
nicktrn 37ce8860b5
fix: all booking and duration limits (#10480)
Co-authored-by: rkreddy99 <rreddy@e2clouds.com>
Co-authored-by: alannnc <alannnc@gmail.com>
2023-08-09 15:51:38 -07:00

17 lines
555 B
TypeScript

import type { IntervalLimit } from "@calcom/types/Calendar";
import { ascendingLimitKeys } from "./intervalLimit";
export const validateIntervalLimitOrder = (input: IntervalLimit) => {
// Sort limits by validationOrder
const sorted = Object.entries(input)
.sort(([, value], [, valuetwo]) => {
return value - valuetwo;
})
.map(([key]) => key);
const validationOrderWithoutMissing = ascendingLimitKeys.filter((key) => sorted.includes(key));
return sorted.every((key, index) => validationOrderWithoutMissing[index] === key);
};