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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { PropertyKey, PropertyKey$inboundSchema } from "./propertykey.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * Represents an error encountered while parsing a value to match the schema
 */
export type Issue = {
  /**
   * The path to the property where the issue occurred
   */
  path: Array<PropertyKey>;
  /**
   * A descriptive message explaining the issue
   */
  message: string;
};

/** @internal */
export const Issue$inboundSchema: z.ZodType<Issue, z.ZodTypeDef, unknown> = z
  .object({
    path: z.array(PropertyKey$inboundSchema),
    message: types.string(),
  });

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