/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: ecb7ef0a0ee3
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type Loc = string | number;

export type Context = {};

export type ValidationError = {
  loc: Array<string | number>;
  msg: string;
  type: string;
  input?: any | undefined;
  ctx?: Context | undefined;
};

/** @internal */
export const Loc$inboundSchema: z.ZodType<Loc, unknown> = smartUnion([
  z.string(),
  z.int(),
]);

export function locFromJSON(
  jsonString: string,
): SafeParseResult<Loc, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Loc$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Loc' from JSON`,
  );
}

/** @internal */
export const Context$inboundSchema: z.ZodType<Context, unknown> = z.object({});

export function contextFromJSON(
  jsonString: string,
): SafeParseResult<Context, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Context$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Context' from JSON`,
  );
}

/** @internal */
export const ValidationError$inboundSchema: z.ZodType<
  ValidationError,
  unknown
> = z.object({
  loc: z.array(smartUnion([z.string(), z.int()])),
  msg: z.string(),
  type: z.string(),
  input: z.any().optional(),
  ctx: z.lazy(() => Context$inboundSchema).optional(),
});

export function validationErrorFromJSON(
  jsonString: string,
): SafeParseResult<ValidationError, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ValidationError$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ValidationError' from JSON`,
  );
}
