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

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

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

/**
 * Schema to update a custom field of type select.
 */
export type CustomFieldUpdateSelect = {
  /**
   * 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: "select";
  properties?: CustomFieldSelectProperties | null | undefined;
};

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

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

export function customFieldUpdateSelectMetadataToJSON(
  customFieldUpdateSelectMetadata: CustomFieldUpdateSelectMetadata,
): string {
  return JSON.stringify(
    CustomFieldUpdateSelectMetadata$outboundSchema.parse(
      customFieldUpdateSelectMetadata,
    ),
  );
}

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

/** @internal */
export const CustomFieldUpdateSelect$outboundSchema: z.ZodMiniType<
  CustomFieldUpdateSelect$Outbound,
  CustomFieldUpdateSelect
> = 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("select"),
  properties: z.optional(
    z.nullable(CustomFieldSelectProperties$outboundSchema),
  ),
});

export function customFieldUpdateSelectToJSON(
  customFieldUpdateSelect: CustomFieldUpdateSelect,
): string {
  return JSON.stringify(
    CustomFieldUpdateSelect$outboundSchema.parse(customFieldUpdateSelect),
  );
}
