/*
 * 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 AiConfigsModification = {
  date?: Date | undefined;
};

/** @internal */
export const AiConfigsModification$inboundSchema: z.ZodType<
  AiConfigsModification,
  z.ZodTypeDef,
  unknown
> = z.object({
  date: z.string().datetime({ offset: true }).transform(v => new Date(v))
    .optional(),
});
/** @internal */
export type AiConfigsModification$Outbound = {
  date?: string | undefined;
};

/** @internal */
export const AiConfigsModification$outboundSchema: z.ZodType<
  AiConfigsModification$Outbound,
  z.ZodTypeDef,
  AiConfigsModification
> = z.object({
  date: z.date().transform(v => v.toISOString()).optional(),
});

export function aiConfigsModificationToJSON(
  aiConfigsModification: AiConfigsModification,
): string {
  return JSON.stringify(
    AiConfigsModification$outboundSchema.parse(aiConfigsModification),
  );
}
export function aiConfigsModificationFromJSON(
  jsonString: string,
): SafeParseResult<AiConfigsModification, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AiConfigsModification$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AiConfigsModification' from JSON`,
  );
}
