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

import * as z from "zod";
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())]);

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace CompletionArgsStop$ {
  /** @deprecated use `CompletionArgsStop$inboundSchema` instead. */
  export const inboundSchema = CompletionArgsStop$inboundSchema;
  /** @deprecated use `CompletionArgsStop$outboundSchema` instead. */
  export const outboundSchema = CompletionArgsStop$outboundSchema;
  /** @deprecated use `CompletionArgsStop$Outbound` instead. */
  export type Outbound = CompletionArgsStop$Outbound;
}

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`,
  );
}
