/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 { TaxRequirementMetadata, TaxRequirementMetadata$inboundSchema, } from "./taxrequirementmetadata.js"; import { TaxRequirementsValue, TaxRequirementsValue$inboundSchema, } from "./taxrequirementsvalue.js"; /** * The required value of the requirement identified by `key` */ export type TaxRequirementValue = boolean | string | number; export type ApplicableIf = { /** * An identifier for an individual requirement. Uniqueness is guaranteed within a requirement set. */ key?: string | undefined; /** * The required value of the requirement identified by `key` */ value?: boolean | string | number | null | undefined; }; export type TaxRequirement = { /** * An identifier for an individual requirement. Uniqueness is guaranteed within a requirement set. */ key?: string | undefined; /** * An array of references to other requirements within the requirement set. This requirement is only applicable if all referenced requirements have values matching the corresponding `value`. The primary use-case is dynamically hiding and showing requirements as values change. E.g. Show Requirement-B when Requirement-A has been answered with `false`. To be explicit, an empty array means the requirement is applicable. */ applicableIf?: Array | undefined; /** * A customer facing description of the requirement */ label?: string | undefined; /** * A more detailed customer facing description of the requirement */ description?: string | null | undefined; /** * The value or "answer" for a tax requirement. Type depends on the requirement metadata type (e.g. string for text/account_number, boolean for radio/checkbox, number for percent/currency/tax_rate). Null when the requirement has not been answered. */ value?: TaxRequirementsValue | null | undefined; metadata?: TaxRequirementMetadata | undefined; /** * Whether the value of this requirement can be updated */ editable?: boolean | undefined; }; /** @internal */ export const TaxRequirementValue$inboundSchema: z.ZodType< TaxRequirementValue, z.ZodTypeDef, unknown > = z.union([z.boolean(), z.string(), z.number()]); export function taxRequirementValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRequirementValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRequirementValue' from JSON`, ); } /** @internal */ export const ApplicableIf$inboundSchema: z.ZodType< ApplicableIf, z.ZodTypeDef, unknown > = z.object({ key: z.string().optional(), value: z.nullable(z.union([z.boolean(), z.string(), z.number()])).optional(), }); export function applicableIfFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApplicableIf$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApplicableIf' from JSON`, ); } /** @internal */ export const TaxRequirement$inboundSchema: z.ZodType< TaxRequirement, z.ZodTypeDef, unknown > = z.object({ key: z.string().optional(), applicable_if: z.array(z.lazy(() => ApplicableIf$inboundSchema)).optional(), label: z.string().optional(), description: z.nullable(z.string()).optional(), value: z.nullable(TaxRequirementsValue$inboundSchema).optional(), metadata: TaxRequirementMetadata$inboundSchema.optional(), editable: z.boolean().optional(), }).transform((v) => { return remap$(v, { "applicable_if": "applicableIf", }); }); export function taxRequirementFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRequirement$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRequirement' from JSON`, ); }