/*
 * 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 * as types from "../../types/primitives.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  TabExtensionData,
  TabExtensionData$inboundSchema,
} from "./tabextensiondata.js";

export type Tab = {
  extensionData: TabExtensionData;
  /**
   * Indicates the type of tab
   */
  tabType: string;
  /**
   * A regular expression used to validate input for the tab.
   */
  validationPattern?: string | undefined;
  /**
   * The message displayed if the custom tab fails input validation
   */
  validationMessage?: string | undefined;
  /**
   * The label associated to a verification field in a document.
   */
  tabLabel: string;
  /**
   * The radio button properties for the tab (if the tab is of radio type)
   */
  radios?: Array<string> | undefined;
};

/** @internal */
export const Tab$inboundSchema: z.ZodType<Tab, z.ZodTypeDef, unknown> = z
  .object({
    extensionData: TabExtensionData$inboundSchema,
    tabType: types.string(),
    validationPattern: types.optional(types.string()),
    validationMessage: types.optional(types.string()),
    tabLabel: types.string(),
    radios: types.optional(z.array(types.string())),
  });

export function tabFromJSON(
  jsonString: string,
): SafeParseResult<Tab, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Tab$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Tab' from JSON`,
  );
}
