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

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";

export type JudgeRegressionOutput = {
  type: "REGRESSION";
  min?: number | undefined;
  minDescription: string;
  max?: number | undefined;
  maxDescription: string;
};

/** @internal */
export const JudgeRegressionOutput$inboundSchema: z.ZodType<
  JudgeRegressionOutput,
  unknown
> = z.object({
  type: z.literal("REGRESSION"),
  min: z.number().default(0),
  min_description: z.string(),
  max: z.number().default(1),
  max_description: z.string(),
}).transform((v) => {
  return remap$(v, {
    "min_description": "minDescription",
    "max_description": "maxDescription",
  });
});
/** @internal */
export type JudgeRegressionOutput$Outbound = {
  type: "REGRESSION";
  min: number;
  min_description: string;
  max: number;
  max_description: string;
};

/** @internal */
export const JudgeRegressionOutput$outboundSchema: z.ZodType<
  JudgeRegressionOutput$Outbound,
  JudgeRegressionOutput
> = z.object({
  type: z.literal("REGRESSION"),
  min: z.number().default(0),
  minDescription: z.string(),
  max: z.number().default(1),
  maxDescription: z.string(),
}).transform((v) => {
  return remap$(v, {
    minDescription: "min_description",
    maxDescription: "max_description",
  });
});

export function judgeRegressionOutputToJSON(
  judgeRegressionOutput: JudgeRegressionOutput,
): string {
  return JSON.stringify(
    JudgeRegressionOutput$outboundSchema.parse(judgeRegressionOutput),
  );
}
export function judgeRegressionOutputFromJSON(
  jsonString: string,
): SafeParseResult<JudgeRegressionOutput, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => JudgeRegressionOutput$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'JudgeRegressionOutput' from JSON`,
  );
}
