Raw
1 import { isDate, MedusaError } from "@medusajs/framework/utils"
2
3 export const validatePriceListDates = (priceListData: {
4 starts_at?: Date | string | null
5 ends_at?: Date | string | null
6 }) => {
7 if (!!priceListData.starts_at && !isDate(priceListData.starts_at)) {
8 throw new MedusaError(
9 MedusaError.Types.INVALID_DATA,
10 `Cannot set price list starts at with with invalid date string: ${priceListData.starts_at}`
11 )
12 }
13
14 if (!!priceListData.ends_at && !isDate(priceListData.ends_at)) {
15 throw new MedusaError(
16 MedusaError.Types.INVALID_DATA,
17 `Cannot set price list ends at with with invalid date string: ${priceListData.ends_at}`
18 )
19 }
20 }