/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { MoovError } from "./mooverror.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type FileT = { filename?: string | undefined; mimeType?: string | undefined; }; export type FileUploadValidationErrorData = { evidenceType?: string | undefined; file?: FileT | undefined; }; export class FileUploadValidationError extends MoovError { evidenceType?: string | undefined; file?: FileT | undefined; /** The original data that was passed to this error instance. */ data$: FileUploadValidationErrorData; constructor( err: FileUploadValidationErrorData, 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.evidenceType != null) this.evidenceType = err.evidenceType; if (err.file != null) this.file = err.file; this.name = "FileUploadValidationError"; } } /** @internal */ export const FileT$inboundSchema: z.ZodType = z .object({ filename: z.string().optional(), mimeType: z.string().optional(), }); /** @internal */ export type FileT$Outbound = { filename?: string | undefined; mimeType?: string | undefined; }; /** @internal */ export const FileT$outboundSchema: z.ZodType< FileT$Outbound, z.ZodTypeDef, FileT > = z.object({ filename: z.string().optional(), mimeType: z.string().optional(), }); export function fileToJSON(fileT: FileT): string { return JSON.stringify(FileT$outboundSchema.parse(fileT)); } export function fileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileT' from JSON`, ); } /** @internal */ export const FileUploadValidationError$inboundSchema: z.ZodType< FileUploadValidationError, z.ZodTypeDef, unknown > = z.object({ evidenceType: z.string().optional(), file: z.lazy(() => FileT$inboundSchema).optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new FileUploadValidationError(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type FileUploadValidationError$Outbound = { evidenceType?: string | undefined; file?: FileT$Outbound | undefined; }; /** @internal */ export const FileUploadValidationError$outboundSchema: z.ZodType< FileUploadValidationError$Outbound, z.ZodTypeDef, FileUploadValidationError > = z.instanceof(FileUploadValidationError) .transform(v => v.data$) .pipe(z.object({ evidenceType: z.string().optional(), file: z.lazy(() => FileT$outboundSchema).optional(), }));