Files
web/server/routers/hotels/schemas/hotel/merchantInformation.ts
2025-02-25 10:45:45 +01:00

24 lines
743 B
TypeScript

import { z } from "zod"
import { nullableStringValidator } from "@/utils/zod/stringValidator"
import type { PaymentMethodEnum } from "@/constants/booking"
export const merchantInformationSchema = z.object({
alternatePaymentOptions: z
.record(z.string(), z.boolean())
.transform((val) => {
return Object.entries(val)
.filter(([_, enabled]) => enabled)
.map(([key]) => key)
.filter((key): key is PaymentMethodEnum => !!key)
}),
cards: z.record(z.string(), z.boolean()).transform((val) => {
return Object.entries(val)
.filter(([_, enabled]) => enabled)
.map(([key]) => key)
.filter((key): key is PaymentMethodEnum => !!key)
}),
webMerchantId: nullableStringValidator,
})