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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ObservabilityErrorCode,
  ObservabilityErrorCode$inboundSchema,
} from "./observabilityerrorcode.js";

export type ObservabilityErrorDetail = {
  message: string;
  errorCode: ObservabilityErrorCode | null;
};

/** @internal */
export const ObservabilityErrorDetail$inboundSchema: z.ZodType<
  ObservabilityErrorDetail,
  unknown
> = z.object({
  message: z.string(),
  error_code: z.nullable(ObservabilityErrorCode$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "error_code": "errorCode",
  });
});

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