/*
 * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type BatchError = {
  message: string;
  count: number | undefined;
};

/** @internal */
export const BatchError$inboundSchema: z.ZodType<
  BatchError,
  z.ZodTypeDef,
  unknown
> = z.object({
  message: z.string(),
  count: z.number().int().default(1),
});

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