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

import * as z from "zod/v4-mini";
import { smartUnion } from "../../types/smartUnion.js";
import {
  CustomFieldDateProperties,
  CustomFieldDateProperties$Outbound,
  CustomFieldDateProperties$outboundSchema,
} from "./customfielddateproperties.js";

export type CustomFieldUpdateDateMetadata = string | number | number | boolean;

/**
 * Schema to update a custom field of type date.
 */
export type CustomFieldUpdateDate = {
  /**
   * Key-value object allowing you to store additional information.
   *
   * @remarks
   *
   * The key must be a string with a maximum length of **40 characters**.
   * The value must be either:
   *
   * * A string with a maximum length of **500 characters**
   * * An integer
   * * A floating-point number
   * * A boolean
   *
   * You can store up to **50 key-value pairs**.
   */
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  name?: string | null | undefined;
  slug?: string | null | undefined;
  type: "date";
  properties?: CustomFieldDateProperties | null | undefined;
};

/** @internal */
export type CustomFieldUpdateDateMetadata$Outbound =
  | string
  | number
  | number
  | boolean;

/** @internal */
export const CustomFieldUpdateDateMetadata$outboundSchema: z.ZodMiniType<
  CustomFieldUpdateDateMetadata$Outbound,
  CustomFieldUpdateDateMetadata
> = smartUnion([z.string(), z.int(), z.number(), z.boolean()]);

export function customFieldUpdateDateMetadataToJSON(
  customFieldUpdateDateMetadata: CustomFieldUpdateDateMetadata,
): string {
  return JSON.stringify(
    CustomFieldUpdateDateMetadata$outboundSchema.parse(
      customFieldUpdateDateMetadata,
    ),
  );
}

/** @internal */
export type CustomFieldUpdateDate$Outbound = {
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  name?: string | null | undefined;
  slug?: string | null | undefined;
  type: "date";
  properties?: CustomFieldDateProperties$Outbound | null | undefined;
};

/** @internal */
export const CustomFieldUpdateDate$outboundSchema: z.ZodMiniType<
  CustomFieldUpdateDate$Outbound,
  CustomFieldUpdateDate
> = z.object({
  metadata: z.optional(
    z.record(
      z.string(),
      smartUnion([z.string(), z.int(), z.number(), z.boolean()]),
    ),
  ),
  name: z.optional(z.nullable(z.string())),
  slug: z.optional(z.nullable(z.string())),
  type: z.literal("date"),
  properties: z.optional(z.nullable(CustomFieldDateProperties$outboundSchema)),
});

export function customFieldUpdateDateToJSON(
  customFieldUpdateDate: CustomFieldUpdateDate,
): string {
  return JSON.stringify(
    CustomFieldUpdateDate$outboundSchema.parse(customFieldUpdateDate),
  );
}
