import type { AreExact, IsUnion } from '../types/global';
declare const descriptionSymbol: unique symbol;
declare const requiredSymbol: unique symbol;
declare const undocumentedSymbol: unique symbol;
export declare const unionSymbol: unique symbol;
type ObjectLikeDef<T> = IsUnion<NonNullable<T>> extends true ? OptionsDefs<Exclude<T, undefined>> : T extends object ? keyof T extends never ? never : OptionsDefs<T> : never;
type Singular<T> = T extends any[] ? T[number] : T;
type PrivateSymbols = {
    [descriptionSymbol]?: string;
    [requiredSymbol]?: boolean;
    [undocumentedSymbol]?: boolean;
    [unionSymbol]?: string;
};
export type OptionsDefs<T> = {
    [K in keyof Singular<T>]-?: Validator | ObjectLikeDef<Singular<T>[K]>;
} & PrivateSymbols;
export type TypeUnionDefs<T, K extends string | number | symbol> = {
    [P in K]: OptionsDefs<Omit<Extract<T, {
        type: P;
    }>, 'type'>>;
};
export interface ValidationResult<T> {
    cleared: Partial<T> | null;
    invalid: ValidationError[];
}
export interface ValidatorResult extends ValidationResult<any> {
    valid: boolean;
}
export interface ValidatorContext {
    path: string;
    options: any;
}
export declare enum ErrorType {
    Invalid = "invalid",
    Required = "required",
    Unknown = "unknown"
}
export interface Validator extends Function, PrivateSymbols {
    (value: unknown, context: ValidatorContext): ValidatorResult | boolean;
}
export declare class ValidationError {
    readonly type: ErrorType | `${ErrorType}`;
    readonly description: string | undefined;
    readonly value: any;
    readonly path: string;
    readonly key?: string | undefined;
    protected altPath?: string;
    constructor(type: ErrorType | `${ErrorType}`, description: string | undefined, value: any, path: string, key?: string | undefined);
    setUnionType(unionType: string, path: string): void;
    getPrefix(): string;
    toString(): string;
}
export declare class UnknownError extends ValidationError {
    suggestions: string[];
    key: string;
    constructor(suggestions: string[], value: unknown, path: string, key: string);
    getPrefix(): string;
    getPostfix(): string;
    toString(): string;
}
/**
 * Validates the provided options against the specified definitions.
 * @param options The options object to validate.
 * @param optionsDefs The definitions against which to validate the options.
 * @param path The current path in the options object, for nested properties.
 * @returns An object containing valid options and validation errors.
 */
export declare function validate<T>(options: unknown, optionsDefs: OptionsDefs<T>, path?: string): ValidationResult<T>;
/**
 * Attaches a descriptive message to a validator function.
 * @param validator The validator function to which to attach a description.
 * @param description The description to attach.
 * @returns A new validator function with the attached description.
 */
export declare function attachDescription(validator: Validator, description: string): Validator;
export declare function attachDescription<T>(optionsDefs: OptionsDefs<T>, description: string): OptionsDefs<T>;
/**
 * Marks a validator or option definitions object as required.
 * @param validatorOrDefs The validator or option definitions to mark as required.
 * @returns The modified validator or option definitions, marked as required.
 */
export declare function required<T extends OptionsDefs<any>>(validatorOrDefs: T): T;
export declare function required<T extends OptionsDefs<any>[]>(validatorOrDefs: T): T;
export declare function required(validatorOrDefs: Validator): Validator;
export declare function undocumented(validatorOrDefs: Validator): Validator;
export declare function undocumented<T extends OptionsDefs<any>>(validatorOrDefs: T): T;
/**
 * Creates a validator for ensuring an object matches the provided option definitions.
 * @param defs The option definitions against which to validate an object.
 * @param description (Optional) A description for the validator, defaulting to 'an object'.
 * @returns A validator function for the given option definitions.
 */
export declare const optionsDefs: <T>(defs: OptionsDefs<T>, description?: string, failAll?: boolean) => Validator;
export declare const typeUnion: <T extends {
    type: string;
}>(defs: TypeUnionDefs<T, T['type']>, description: string, defaultType?: T['type']) => OptionsDefs<T>;
/**
 * Combines multiple validators, requiring all to pass.
 * @param validators An array of validators to combine.
 * @returns A validator that requires all specified validators to pass.
 */
export declare const and: (...validators: Validator[]) => Validator;
/**
 * Combines multiple validators, passing if any one of them does.
 * @param validators An array of validators to combine.
 * @returns A validator that passes if any one of the specified validators does.
 */
export declare const or: (...validators: Validator[]) => Validator;
export declare const array: Validator;
export declare const boolean: Validator;
export declare const callback: Validator;
export declare const color: Validator;
export declare const date: Validator;
export declare const defined: Validator;
export declare const number: Validator;
export declare const object: Validator;
export declare const string: Validator;
export declare const htmlElement: Validator;
export declare const arrayLength: (minLength: number, maxLength?: number) => Validator;
export declare const stringLength: (minLength: number, maxLength?: number) => Validator;
export declare const numberMin: (min: number, inclusive?: boolean) => Validator;
export declare const numberRange: (min: number, max: number) => Validator;
export declare const positiveNumber: Validator;
export declare const positiveNumberNonZero: Validator;
export declare const ratio: Validator;
export declare const lessThan: (otherField: string) => Validator;
export declare const lessThanOrEqual: (otherField: string) => Validator;
export declare const greaterThan: (otherField: string) => Validator;
/**
 * Creates a validator for a union of allowed values.
 * @param allowed An array of allowed values.
 * @returns A validator function that checks if a value is among the allowed ones.
 */
export declare function union(allowed: object): Validator;
export declare function union(...allowed: any[]): Validator;
/**
 * A defensive version of `union` that intentionally breaks compilation if a string union type is changed.
 * @example
 * type U = 'a' | 'b';
 * strictUnion<U>()('a', 'b'); // compilation breaks if U is changed to `'a' | 'b' | 'c'`.
 */
export declare function strictUnion<T extends string>(): <U extends readonly T[]>(...args: U & (AreExact<T, U[number]> extends true ? U : never)) => Validator;
/**
 * Creates a validator for a single constant value.
 * @param allowed The allowed constant value.
 * @returns A validator function that checks for equality with the allowed value.
 */
export declare const constant: (allowed: boolean | number | string) => Validator;
/**
 * Creates a validator for instances of a specific class.
 * @param instanceType The constructor of the class to check instances against.
 * @param description An optional description string.
 * @returns A validator function that checks if a value is an instance of the specified class.
 */
export declare const instanceOf: (instanceType: Function, description?: string) => Validator;
/**
 * Creates a validator for arrays where every element must pass a given validator.
 * @param validator The validator to apply to each array element.
 * @param description An optional description string.
 * @param strict When enabled validator fails on any invalid item, otherwise invalid items are filtered.
 * @returns A validator function for arrays with elements validated by the specified validator.
 */
export declare const arrayOf: (validator: Validator, description?: string, strict?: boolean) => Validator;
/**
 * Creates a validator for arrays where each element is validated against a given set of definitions.
 * Allows capturing both valid and invalid values while providing detailed validation errors.
 * @param defs The validation definitions to apply to each array element.
 * @param description An optional description string.
 * @returns A validator function for arrays, storing valid elements and collecting errors for invalid ones.
 */
export declare const arrayOfDefs: <T>(defs: OptionsDefs<T>, description?: string) => Validator;
export declare const callbackOf: (validator: Validator, description?: string) => Validator;
export declare const callbackDefs: <T>(defs: OptionsDefs<T>, description?: string) => Validator;
export declare function hasRequiredInPath(errors: ValidationError[], rootPath: string): boolean;
export {};
