21 lines
504 B
TypeScript
21 lines
504 B
TypeScript
import { TRPCError } from "@trpc/server";
|
|
|
|
export function assertTimelineDateRangeValid(startDate: Date, endDate: Date): void {
|
|
if (endDate >= startDate) {
|
|
return;
|
|
}
|
|
|
|
throw new TRPCError({
|
|
code: "BAD_REQUEST",
|
|
message: "End date must be after start date",
|
|
});
|
|
}
|
|
|
|
export function validateTimelineAllocationDateRanges(
|
|
ranges: Array<{ startDate: Date; endDate: Date }>,
|
|
): void {
|
|
for (const range of ranges) {
|
|
assertTimelineDateRangeValid(range.startDate, range.endDate);
|
|
}
|
|
}
|