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

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 JSONPatchAdd = {
  /**
   * 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;
  /**
   * Add operation
   */
  op: "add";
};

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

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