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

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";
import { JSONPatch, JSONPatch$inboundSchema } from "./jsonpatch.js";

export type JSONPatchPayloadValueResponse = Array<JSONPatch> | string;

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

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