/*
 * 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 CompletionArgsStop = string | Array<string>;

/** @internal */
export const CompletionArgsStop$inboundSchema: z.ZodType<
  CompletionArgsStop,
  z.ZodTypeDef,
  unknown
> = z.union([z.string(), z.array(z.string())]);
/** @internal */
export type CompletionArgsStop$Outbound = string | Array<string>;

/** @internal */
export const CompletionArgsStop$outboundSchema: z.ZodType<
  CompletionArgsStop$Outbound,
  z.ZodTypeDef,
  CompletionArgsStop
> = z.union([z.string(), z.array(z.string())]);

export function completionArgsStopToJSON(
  completionArgsStop: CompletionArgsStop,
): string {
  return JSON.stringify(
    CompletionArgsStop$outboundSchema.parse(completionArgsStop),
  );
}
export function completionArgsStopFromJSON(
  jsonString: string,
): SafeParseResult<CompletionArgsStop, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CompletionArgsStop$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CompletionArgsStop' from JSON`,
  );
}
