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

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

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

/** @internal */
export const CompletionArgsStop$outboundSchema: z.ZodType<
  CompletionArgsStop$Outbound,
  CompletionArgsStop
> = smartUnion([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`,
  );
}
