fix(medusa, pricing, types): pass dates as Date-objects rather than strings to the pricing module (#5768)
* init * remove date string validator; * add transformOptionalDate transformer to api * move type conversion to the datalayer * fix final module integration test * update arrow-function * make string optional * move work to utils * make check for value exists * move util back to pricng * change utils * refactor get-iso-string * fix build * flip transform condition * add null check for isDate * feat(pricing): Separate Pricing Module internal types from `@medusajs/types` (#5777) * create types for pricing repositories * create RepositoryTypes input * add service types * use models for repository types * fix build * update types to match interface types * add aliases * types instead of moduletypes * move repository to types for pricing module * add changeset * fix merge error * fix conflict * fix build * re-add validation of dates in updatePriceLists_
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from "./validate-price-list-dates"
|
||||
@@ -0,0 +1,20 @@
|
||||
import { isDate, MedusaError } from "@medusajs/utils"
|
||||
|
||||
export const validatePriceListDates = (priceListData: {
|
||||
starts_at?: Date | string | null
|
||||
ends_at?: Date | string | null
|
||||
}) => {
|
||||
if (!!priceListData.starts_at && !isDate(priceListData.starts_at)) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Cannot set price list starts at with with invalid date string: ${priceListData.starts_at}`
|
||||
)
|
||||
}
|
||||
|
||||
if (!!priceListData.ends_at && !isDate(priceListData.ends_at)) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Cannot set price list ends at with with invalid date string: ${priceListData.ends_at}`
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user