/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Context = {}; export type Loc = string | number; export type ValidationError = { ctx?: Context | undefined; input?: any | undefined; loc: Array; msg: string; type: string; }; /** @internal */ export const Context$inboundSchema: z.ZodType = z.object({}); /** @internal */ export type Context$Outbound = {}; /** @internal */ export const Context$outboundSchema: z.ZodType< Context$Outbound, z.ZodTypeDef, Context > = z.object({}); export function contextToJSON(context: Context): string { return JSON.stringify(Context$outboundSchema.parse(context)); } export function contextFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Context$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Context' from JSON`, ); } /** @internal */ export const Loc$inboundSchema: z.ZodType = z.union( [z.string(), z.number().int()], ); /** @internal */ export type Loc$Outbound = string | number; /** @internal */ export const Loc$outboundSchema: z.ZodType = z .union([z.string(), z.number().int()]); export function locToJSON(loc: Loc): string { return JSON.stringify(Loc$outboundSchema.parse(loc)); } export function locFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Loc$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Loc' from JSON`, ); } /** @internal */ export const ValidationError$inboundSchema: z.ZodType< ValidationError, z.ZodTypeDef, unknown > = z.object({ ctx: z.lazy(() => Context$inboundSchema).optional(), input: z.any().optional(), loc: z.array(z.union([z.string(), z.number().int()])), msg: z.string(), type: z.string(), }); /** @internal */ export type ValidationError$Outbound = { ctx?: Context$Outbound | undefined; input?: any | undefined; loc: Array; msg: string; type: string; }; /** @internal */ export const ValidationError$outboundSchema: z.ZodType< ValidationError$Outbound, z.ZodTypeDef, ValidationError > = z.object({ ctx: z.lazy(() => Context$outboundSchema).optional(), input: z.any().optional(), loc: z.array(z.union([z.string(), z.number().int()])), msg: z.string(), type: z.string(), }); export function validationErrorToJSON( validationError: ValidationError, ): string { return JSON.stringify(ValidationError$outboundSchema.parse(validationError)); } export function validationErrorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ValidationError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ValidationError' from JSON`, ); }