/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ProductOption, ProductOption$inboundSchema, ProductOption$Outbound, ProductOption$outboundSchema, } from "./productoption.js"; /** * Represents a group of product configuration options, such as size or color. */ export type ProductOptionGroup = { name: string; /** * A detailed description of the option group. * * @remarks * * - Must be valid UTF-8 text * - Supports Markdown for formatting * - HTML is not permitted and will be rejected */ description?: string | undefined; /** * The minimum number of options that must be selected from this group. * * @remarks * * A value of 0 indicates that no selection from this group is required. */ minSelect: number; /** * The maximum number of options that can be selected from this group. */ maxSelect: number; /** * The options available within this group. */ options: Array; }; /** @internal */ export const ProductOptionGroup$inboundSchema: z.ZodType< ProductOptionGroup, z.ZodTypeDef, unknown > = z.object({ name: z.string(), description: z.string().optional(), minSelect: z.number().int(), maxSelect: z.number().int(), options: z.array(ProductOption$inboundSchema), }); /** @internal */ export type ProductOptionGroup$Outbound = { name: string; description?: string | undefined; minSelect: number; maxSelect: number; options: Array; }; /** @internal */ export const ProductOptionGroup$outboundSchema: z.ZodType< ProductOptionGroup$Outbound, z.ZodTypeDef, ProductOptionGroup > = z.object({ name: z.string(), description: z.string().optional(), minSelect: z.number().int(), maxSelect: z.number().int(), options: z.array(ProductOption$outboundSchema), }); export function productOptionGroupToJSON( productOptionGroup: ProductOptionGroup, ): string { return JSON.stringify( ProductOptionGroup$outboundSchema.parse(productOptionGroup), ); } export function productOptionGroupFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProductOptionGroup$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProductOptionGroup' from JSON`, ); }