import { type NeverCoalescing, type UnionToIntersection, type AnyPredicate, type IsExtends, type AnyTuple, type IsNever } from "../../common"; import { type DataParserChecker } from "../baseChecker"; import type * as AllDataParser from "../parsers"; import type * as DDate from "../../date"; import type * as DArray from "../../array"; import { type DataParserDefinition } from "../base"; export interface CheckerCustom { base: DataParserChecker; } export type DataParserCheckers = (CheckerCustom[keyof CheckerCustom] | AllDataParser.DataParserCheckerArrayMax | AllDataParser.DataParserCheckerArrayMin | AllDataParser.DataParserCheckerBigIntMax | AllDataParser.DataParserCheckerBigIntMin | AllDataParser.DataParserCheckerEmail | AllDataParser.DataParserCheckerInt | AllDataParser.DataParserCheckerNumberMax | AllDataParser.DataParserCheckerNumberMin | AllDataParser.DataParserCheckerRegex | AllDataParser.DataParserCheckerRefine | AllDataParser.DataParserCheckerStringMax | AllDataParser.DataParserCheckerStringMin | AllDataParser.DataParserCheckerTimeMax | AllDataParser.DataParserCheckerTimeMin | AllDataParser.DataParserCheckerUrl | AllDataParser.DataParserCheckerUuid); export interface EligibleChecker { base: DataParserChecker; refine: AllDataParser.DataParserCheckerRefine>; array: IsExtends extends true ? (AllDataParser.DataParserCheckerArrayMax | AllDataParser.DataParserCheckerArrayMin) : never; bigInt: IsExtends extends true ? (AllDataParser.DataParserCheckerBigIntMax | AllDataParser.DataParserCheckerBigIntMin) : never; number: IsExtends extends true ? (AllDataParser.DataParserCheckerInt | AllDataParser.DataParserCheckerNumberMax | AllDataParser.DataParserCheckerNumberMin) : never; string: IsExtends extends true ? (AllDataParser.DataParserCheckerEmail | AllDataParser.DataParserCheckerRegex | AllDataParser.DataParserCheckerStringMax | AllDataParser.DataParserCheckerStringMin | AllDataParser.DataParserCheckerUrl | AllDataParser.DataParserCheckerUuid) : never; time: IsExtends extends true ? (AllDataParser.DataParserCheckerTimeMax | AllDataParser.DataParserCheckerTimeMin) : never; } export type GetEligibleChecker = EligibleChecker extends infer InferredResult ? Extract> : never; export interface RefinementOfChecker { refine: GenericChecker extends AllDataParser.DataParserCheckerRefine ? GenericChecker["definition"]["theFunction"] extends AnyPredicate ? InferredPredicate : never : never; arrayMin: GenericChecker extends AllDataParser.DataParserCheckerArrayMin ? number extends GenericChecker["definition"]["min"] ? never : GenericValue extends readonly unknown[] ? [ ...DArray.CreateTuple, ...GenericValue[number][] ] : never : never; arrayMax: GenericChecker extends AllDataParser.DataParserCheckerArrayMax ? number extends GenericChecker["definition"]["max"] ? never : GenericValue & DArray.MaxElements : never; stringEmail: GenericChecker extends AllDataParser.DataParserCheckerEmail ? `${string}@${string}.${string}` : never; } export type ApplyRefinementOfChecker = IsNever extends true ? GenericValue : NeverCoalescing extends infer InferredResult ? InferredResult[keyof InferredResult] : never : never> extends infer InferredResult extends GenericValue ? (InferredResult & GenericValue) : never, GenericValue>; export type ApplyRefinementOfDefinition = ApplyRefinementOfChecker[number]>;