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

import * as z from "zod/v4-mini";
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";
import {
  CustomFieldSelectOption,
  CustomFieldSelectOption$inboundSchema,
  CustomFieldSelectOption$Outbound,
  CustomFieldSelectOption$outboundSchema,
} from "./customfieldselectoption.js";

export type CustomFieldSelectProperties = {
  formLabel?: string | undefined;
  formHelpText?: string | undefined;
  formPlaceholder?: string | undefined;
  options: Array<CustomFieldSelectOption>;
};

/** @internal */
export const CustomFieldSelectProperties$inboundSchema: z.ZodMiniType<
  CustomFieldSelectProperties,
  unknown
> = z.pipe(
  z.object({
    form_label: z.optional(z.string()),
    form_help_text: z.optional(z.string()),
    form_placeholder: z.optional(z.string()),
    options: z.array(CustomFieldSelectOption$inboundSchema),
  }),
  z.transform((v) => {
    return remap$(v, {
      "form_label": "formLabel",
      "form_help_text": "formHelpText",
      "form_placeholder": "formPlaceholder",
    });
  }),
);
/** @internal */
export type CustomFieldSelectProperties$Outbound = {
  form_label?: string | undefined;
  form_help_text?: string | undefined;
  form_placeholder?: string | undefined;
  options: Array<CustomFieldSelectOption$Outbound>;
};

/** @internal */
export const CustomFieldSelectProperties$outboundSchema: z.ZodMiniType<
  CustomFieldSelectProperties$Outbound,
  CustomFieldSelectProperties
> = z.pipe(
  z.object({
    formLabel: z.optional(z.string()),
    formHelpText: z.optional(z.string()),
    formPlaceholder: z.optional(z.string()),
    options: z.array(CustomFieldSelectOption$outboundSchema),
  }),
  z.transform((v) => {
    return remap$(v, {
      formLabel: "form_label",
      formHelpText: "form_help_text",
      formPlaceholder: "form_placeholder",
    });
  }),
);

export function customFieldSelectPropertiesToJSON(
  customFieldSelectProperties: CustomFieldSelectProperties,
): string {
  return JSON.stringify(
    CustomFieldSelectProperties$outboundSchema.parse(
      customFieldSelectProperties,
    ),
  );
}
export function customFieldSelectPropertiesFromJSON(
  jsonString: string,
): SafeParseResult<CustomFieldSelectProperties, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CustomFieldSelectProperties$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CustomFieldSelectProperties' from JSON`,
  );
}
