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

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

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

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

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

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

export function customFieldUpdateCheckboxMetadataToJSON(
  customFieldUpdateCheckboxMetadata: CustomFieldUpdateCheckboxMetadata,
): string {
  return JSON.stringify(
    CustomFieldUpdateCheckboxMetadata$outboundSchema.parse(
      customFieldUpdateCheckboxMetadata,
    ),
  );
}

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

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

export function customFieldUpdateCheckboxToJSON(
  customFieldUpdateCheckbox: CustomFieldUpdateCheckbox,
): string {
  return JSON.stringify(
    CustomFieldUpdateCheckbox$outboundSchema.parse(customFieldUpdateCheckbox),
  );
}
