Files
calendar/packages/trpc/server/routers/publicViewer/stripeCheckoutSession.schema.ts
T
b552bf6956 Fix: #8528 Moved the data checks to superRefine (#8749)
* Fix: #8528 Moved the data checks to superRefine

* Resolved lint isseu

* Updated to parse from safeParse

* added new line

---------

Co-authored-by: Omar López <zomars@me.com>
2023-05-13 04:11:12 +00:00

24 lines
725 B
TypeScript

import { z } from "zod";
export const ZStripeCheckoutSessionInputSchema = z
.object({
stripeCustomerId: z.string().optional(),
checkoutSessionId: z.string().optional(),
})
.superRefine((arg, ctx) => {
if (!arg.checkoutSessionId && !arg.stripeCustomerId) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Missing checkoutSessionId or stripeCustomerId",
});
}
if (arg.checkoutSessionId && arg.stripeCustomerId) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Both checkoutSessionId and stripeCustomerId provided",
});
}
});
export type TStripeCheckoutSessionInputSchema = z.infer<typeof ZStripeCheckoutSessionInputSchema>;