import { type FixDeepFunctionInfer, type NeverCoalescing } from "../../common"; import { type DataParser, type DataParserDefinition } from "../base"; import { type DataParserError } from "../../dataParser/error"; import { type DataParserChecker } from "../baseChecker"; import { type ApplyRefinementOfDefinition, type AddCheckersToDefinition, type GetEligibleChecker, type Input, type MergeDefinition, type Output, type PrepareDataParserDefinition } from "../types"; export type UnionOptions = readonly [DataParser, ...DataParser[]]; export type DataParserUnionCheckers = GetEligibleChecker; export interface DataParserDefinitionUnion extends DataParserDefinition> { readonly options: UnionOptions; } export declare const unionKind: import("../../common").KindHandler>; declare const DataParserUnion_base: import("..").DataParserBaseInit>>; export declare class DataParserUnion extends DataParserUnion_base, GenericDefinition>, ApplyRefinementOfDefinition, GenericDefinition>> { get classConstructor(): typeof DataParserUnion & import("..").CheckedConstructorKind; addChecker: >, ...DataParserChecker>[] ]>(...args: FixDeepFunctionInfer>, ...DataParserChecker>[] ], GenericChecker>) => DataParserUnion>; static execParse(self: DataParserUnion, data: unknown, error: DataParserError): unknown; static dataParserIsAsynchronous(self: DataParserUnion): boolean; static prepareDefinition(options: UnionOptions, definition?: Partial>): DataParserDefinitionUnion; /** * Creates a data parser that accepts one of multiple parsers. * * **Supported call styles:** * - Classic: `DP.union(options, definition?)` -> returns a union parser * - Curried: not available * * Tries each option in order until one succeeds, then returns its output. * * ```ts * const parser = DP.union([DP.string(), DP.number()]); * const result = parser.parse("hello"); * if (E.isRight(result)) { * const value = unwrap(result); * // value: string | number * } * * const literals = DP.union([DP.literal("on"), DP.literal("off")]); * const literalResult = literals.parse("off"); * * const withCheckers = DP.union( * [DP.string(), DP.coerce.number()], * { checkers: [DP.checkerRefine((value) => value !== "forbidden")] }, * ); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/union * * @namespace DP * */ static create>, "options"> = never>(options: GenericOptions, definition?: FixDeepFunctionInfer>, "options">, GenericDefinition>): DataParserUnion & { readonly options: GenericOptions; }>>; } /** * Creates a data parser that accepts one of multiple parsers. * * **Supported call styles:** * - Classic: `DP.union(options, definition?)` -> returns a union parser * - Curried: not available * * Tries each option in order until one succeeds, then returns its output. * * ```ts * const parser = DP.union([DP.string(), DP.number()]); * const result = parser.parse("hello"); * if (E.isRight(result)) { * const value = unwrap(result); * // value: string | number * } * * const literals = DP.union([DP.literal("on"), DP.literal("off")]); * const literalResult = literals.parse("off"); * * const withCheckers = DP.union( * [DP.string(), DP.coerce.number()], * { checkers: [DP.checkerRefine((value) => value !== "forbidden")] }, * ); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/union * * @namespace DP * */ export declare const union: typeof DataParserUnion.create; export {};