/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import * as components from "../components/index.js"; import { MoovError } from "./mooverror.js"; export type ProductRequestValidationErrorData = { title?: string | undefined; description?: string | undefined; basePrice?: components.AmountDecimalValidationError | undefined; images?: | { [k: string]: components.AssignProductImageValidationError } | undefined; optionGroups?: | { [k: string]: components.ProductOptionGroupValidationError } | undefined; }; export class ProductRequestValidationError extends MoovError { title?: string | undefined; description?: string | undefined; basePrice?: components.AmountDecimalValidationError | undefined; images?: | { [k: string]: components.AssignProductImageValidationError } | undefined; optionGroups?: | { [k: string]: components.ProductOptionGroupValidationError } | undefined; /** The original data that was passed to this error instance. */ data$: ProductRequestValidationErrorData; constructor( err: ProductRequestValidationErrorData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.title != null) this.title = err.title; if (err.description != null) this.description = err.description; if (err.basePrice != null) this.basePrice = err.basePrice; if (err.images != null) this.images = err.images; if (err.optionGroups != null) this.optionGroups = err.optionGroups; this.name = "ProductRequestValidationError"; } } /** @internal */ export const ProductRequestValidationError$inboundSchema: z.ZodType< ProductRequestValidationError, z.ZodTypeDef, unknown > = z.object({ title: z.string().optional(), description: z.string().optional(), basePrice: components.AmountDecimalValidationError$inboundSchema.optional(), images: z.record(components.AssignProductImageValidationError$inboundSchema) .optional(), optionGroups: z.record( components.ProductOptionGroupValidationError$inboundSchema, ).optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new ProductRequestValidationError(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type ProductRequestValidationError$Outbound = { title?: string | undefined; description?: string | undefined; basePrice?: components.AmountDecimalValidationError$Outbound | undefined; images?: { [k: string]: components.AssignProductImageValidationError$Outbound; } | undefined; optionGroups?: { [k: string]: components.ProductOptionGroupValidationError$Outbound; } | undefined; }; /** @internal */ export const ProductRequestValidationError$outboundSchema: z.ZodType< ProductRequestValidationError$Outbound, z.ZodTypeDef, ProductRequestValidationError > = z.instanceof(ProductRequestValidationError) .transform(v => v.data$) .pipe(z.object({ title: z.string().optional(), description: z.string().optional(), basePrice: components.AmountDecimalValidationError$outboundSchema .optional(), images: z.record( components.AssignProductImageValidationError$outboundSchema, ).optional(), optionGroups: z.record( components.ProductOptionGroupValidationError$outboundSchema, ).optional(), }));