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

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

export type JSONPatchReplace = {
  /**
   * A JSON Pointer (RFC 6901) identifying the target location within the document. Can be a string path (e.g., '/foo/bar'), '/', '', or an empty list [] for root-level operations.
   */
  path: string;
  /**
   * The value to use for the operation
   */
  value: any;
  /**
   * Replace operation
   */
  op: "replace";
};

/** @internal */
export const JSONPatchReplace$inboundSchema: z.ZodType<
  JSONPatchReplace,
  unknown
> = z.object({
  path: z.string(),
  value: z.any(),
  op: z.literal("replace"),
});

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