declare type UndefinedPropKeys = { [K in keyof T]-?: undefined extends T[K] ? K : never; }[keyof T]; declare type SelectivePartial = Partial> & Required>> extends infer U ? { [P in keyof U]: U[P]; } : never; interface IError { readonly toPrimitiveError: () => T; } declare const STRUCTURE: unique symbol; interface IStructure { readonly [STRUCTURE]: true; } interface ILogicalOperator { readonly type: string; readonly operator: string; readonly errors: T[]; } declare class LogicalOperatorError implements ILogicalOperator, IError | string> { type: string; operator: string; errors: T; constructor(operator: string, errors: T); toPrimitiveError(): string | ILogicalOperator; toJSON(): string | ILogicalOperator; toString(): string; } declare class ORError extends LogicalOperatorError { constructor(errors: T); } declare class ANDError extends LogicalOperatorError { constructor(errors: T); } declare class XORError extends LogicalOperatorError { constructor(errors: T); } interface IPeerError { readonly type: string; readonly key: string; readonly error: T; } declare class PeerError implements IPeerError, IError | string> { type: string; key: string; error: T; constructor(key: string, error: T); toPrimitiveError(): string | IPeerError; toJSON(): string | IPeerError; toString(): string; } interface INegateError { readonly type: string; readonly error: T; } declare class NegateError implements INegateError, IError | string> { type: string; error: T; constructor(error: T); toPrimitiveError(): string | INegateError; toJSON(): string | INegateError; toString(): string; } declare type Validator = ((value: unknown, ...parents: any[]) => Err | undefined) & ValidatorTypeMeta; declare type StructValidator = ((value: unknown, ...parents: any[]) => Err) & ValidatorTypeMeta; declare type ExtractErr> = Exclude, undefined>; declare type ValidatorTypeMeta = { readonly __typeMeta?: { readonly validType: ValidType; }; }; declare type Infer> = Exclude['validType']; declare const annotate: () => >(validator: V) => Validator>, undefined>>; interface ErrItem { readonly path: string; readonly err: Err; } declare const listErrors: (err: any) => ErrItem[]; declare const isError: (err: Err) => err is Exclude; declare const hasError: (err: Err) => err is Exclude; interface AssertErrParams { readonly error: Err; readonly errorList: ErrItem[]; } declare function assert(value: unknown, validator: V, logValue?: true): asserts value is Infer; declare function assert(value: unknown, validator: V, message: string): asserts value is Infer; declare function assert(value: unknown, validator: V, error: Error): asserts value is Infer; declare function assert(value: unknown, validator: V, createError: (params: AssertErrParams>) => Error | string): asserts value is Infer; declare const ONE_SIDED: unique symbol; declare type OneSided = T & { readonly [ONE_SIDED]?: void; }; declare const okay: >(value: unknown, validator: V) => value is OneSided>; declare const withErr: >(validator: V, err: Err) => Validator, Err>; declare const err: >(validator: V, err: Err) => Validator, Err>; declare const INTROSPECT: unique symbol; declare const create: (predicate: (value: unknown, ...parents: any[]) => boolean) => (err: Err) => Validator; declare const is: (value: ValidType) => Validator; declare const typeOf: (str: string) => Validator; declare const instanceOf: (ctor: new (...args: any[]) => T) => Validator; declare const number: Validator; declare const boolean: Validator; declare const bigint: Validator; declare const string: Validator; declare const symbol: Validator; declare const fn: Validator; declare const undef: Validator; declare const nul: Validator; declare const integer: Validator; declare const finite: Validator; declare type ArrReturnTypes any)[]> = { [I in keyof T]: ReturnType any ? T[I] : never>; }; declare const or: []>(...validators: V) => Validator, ORError[number], undefined>[]>>; declare const xor: []>(...validators: V) => Validator, XORError[number], undefined>[]>>; declare const and: []>(...validators: V) => Validator, ANDError[number], undefined>[]>>; declare const arr: Validator; declare const maxLength: (len: number) => Validator; declare const minLength: (len: number) => Validator; declare const length: (min: number, max?: number) => Validator; declare const min: (num: number) => Validator; declare const max: (num: number) => Validator; declare const nullish: Validator; declare const includes: (value: any) => Validator; declare const pattern: (regex: RegExp) => Validator; declare const oneOf: (...allowed: T) => Validator; declare const not: (validator: Validator) => Validator>; declare type ArrayErrorStruct> = (ExtractErr | string | undefined)[] & IStructure; declare const array: >(validator: V) => StructValidator[], ArrayErrorStruct>; declare type TupleErrorStruct[]> = Exclude[number] | string, undefined>[] & IStructure; declare const tuple: []>(...validators: V) => StructValidator[], TupleErrorStruct>; declare const all: []>(...validators: V) => Validator, ANDError[number], undefined>[]>>; declare type ObjReturnTypes any>> = { [P in keyof T]: ReturnType; }; declare const OBJECT_ROOT: unique symbol; declare type ObjectErrorStruct any>> = ObjReturnTypes & { [OBJECT_ROOT]?: string; } & IStructure; declare type _InferObject any>> = { [P in keyof T]: T[P] extends Validator ? Infer : never; }; declare const object: any>>(validators: Validators, { allowUnknown }?: { allowUnknown?: boolean | undefined; }) => StructValidator, UndefinedPropKeys<_InferObject>>, ObjectErrorStruct>; declare function merge(validator: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator, validator3: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator, validator3: Validator, validator4: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator, validator3: Validator, validator4: Validator, validator5: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator, validator3: Validator, validator4: Validator, validator5: Validator, validator6: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator, validator3: Validator, validator4: Validator, validator5: Validator, validator6: Validator, validator7: Validator): StructValidator; declare function merge(validator1: Validator, validator2: Validator, validator3: Validator, validator4: Validator, validator5: Validator, validator6: Validator, validator7: Validator, validator8: Validator): StructValidator; declare const when: (predicate: (value: unknown, ...parents: any[]) => boolean) => (validator: Validator) => Validator>; declare const match: (key: string) => Validator; declare const email: Validator; declare const peer: (key: string) => (validator: Validator) => Validator>; declare const andPeers: (...keys: string[]) => Validator)[]> | ANDError<(NegateError | PeerError>)[]>)[]>>; declare const andPeer: (key: string) => Validator)[]> | ANDError<(NegateError | PeerError>)[]>)[]>>; declare const nandPeers: (...keys: string[]) => Validator)[]> | NegateError | PeerError>)[]>>)[]>>; declare const nandPeer: (key: string) => Validator)[]> | NegateError | PeerError>)[]>>)[]>>; declare const orPeers: (...keys: string[]) => Validator | PeerError>)[]>>; declare const orPeer: (key: string) => Validator | PeerError>)[]>>; declare const xorPeers: (...keys: string[]) => Validator | PeerError>)[]>>; declare const xorPeer: (key: string) => Validator | PeerError>)[]>>; declare const oxorPeers: (...keys: string[]) => Validator)[]> | XORError<(NegateError | PeerError>)[]>)[]>>; declare const oxorPeer: (key: string) => Validator)[]> | XORError<(NegateError | PeerError>)[]>)[]>>; declare const exists: Validator<{}, NegateError>; declare const truthy: Validator<{}, string>; declare type Falsy = false | null | undefined | '' | number; declare const falsy: Validator; export { ArrayErrorStruct, AssertErrParams, ErrItem, ExtractErr, Falsy, INTROSPECT, Infer, OBJECT_ROOT, ObjectErrorStruct, StructValidator, TupleErrorStruct, Validator, ValidatorTypeMeta, all, and, andPeer, andPeers, annotate, arr, array, assert, bigint, boolean, create, email, err, exists, falsy, finite, fn, hasError, includes, instanceOf, integer, is, isError, length, listErrors, match, max, maxLength, merge, min, minLength, nandPeer, nandPeers, not, nul, nullish, number, object, okay, oneOf, or, orPeer, orPeers, oxorPeer, oxorPeers, pattern, peer, string, symbol, truthy, tuple, typeOf, undef, when, withErr, xor, xorPeer, xorPeers };