import type { AbolishRule, AbolishSchema, AbolishValidator, ValidationError, ValidationResult } from "./types"; import { AbolishCompiled, AbolishCompiledObject } from "./Compiler"; export declare class AttemptError extends Error { error: ValidationError; constructor(e: ValidationError); static instanceOf(e: any): boolean; } /** * Abolish Super Rules and Keys */ export declare const SuperKeys: Readonly<{ Wildcards: Set; Fields: Set; Rules: Set; }>; interface AbolishConfig { useStartCaseInErrors?: boolean; } /** * Abolish Class * @class */ declare class Abolish { validators: Record; config: AbolishConfig; /** * Get global validators */ static getGlobalValidators(): Record; /** * Get global validators list */ static getGlobalValidatorsList(): string[]; /** * Add single global validator * @param validator */ static addGlobalValidator(validator: AbolishValidator): typeof Abolish; /** * Add multiple global validators * @param validators */ static addGlobalValidators(validators: AbolishValidator[] | Record): typeof Abolish; /** * Toggle start case in error. * @param value */ useStartCaseInErrors(value?: boolean): this; /** * addValidator * @description * Add validator or array of validators * @param validator */ addValidator(validator: AbolishValidator): this; /** * addValidators * @description * Add validator or array of validators * @param validators */ addValidators(validators: AbolishValidator[] | Record): this; /** * Validate * @description * Validates given object with rules defined on Abolish instance * @param {object} object * @param {object} rules */ static validate = Record>(object: Record, rules: AbolishSchema): ValidationResult; static validate>(object: Record, rules: AbolishCompiledObject): ValidationResult; /** * Validate Async * * Waits for all validation defined * @param object * @param rules * @return {Promise} */ static validateAsync = Record>(object: Record, rules: Record): Promise>; /** * Validate * @description * Validates given object with rules defined on Abolish instance * @param {object} object * @param {object} rules * @param {boolean} isAsync */ validate = Record>(object: Record, rules: AbolishSchema, isAsync?: boolean): ValidationResult; validate>(object: Record, rules: AbolishCompiledObject, isAsync?: boolean): ValidationResult; /** * Validate Async * * Waits for all validation defined * @param object * @param rules * @return {Promise} */ validateAsync = Record>(object: Record, rules: AbolishSchema): Promise>; validateAsync>(object: Record, rules: AbolishCompiledObject): Promise>; /** * check a variable does not throw error * @param variable * @param rules */ check(variable: V, rules: AbolishRule | AbolishCompiled): ValidationResult; /** * Static Check * @param variable * @param rules */ static check(variable: V, rules: AbolishRule | AbolishCompiled): ValidationResult; /** * Checks a variable Asynchronously * @param variable * @param rules */ checkAsync(variable: V, rules: AbolishRule | AbolishCompiled): Promise>; /** * Static Check Async * @param variable * @param rules */ static checkAsync(variable: V, rules: AbolishRule): Promise>; /** * Validates a variable * @param variable * @param rules */ attempt(variable: V, rules: AbolishRule | AbolishCompiled): V; /** * Static Attempt * @param variable * @param rules * @param abolish */ static attempt(variable: V, rules: AbolishRule | AbolishCompiled): V; /** * Validates a variable Asynchronously, Throws error * @param variable * @param rules */ attemptAsync(variable: V, rules: AbolishRule | AbolishCompiled): Promise; /** * Validates a variable Asynchronously, Throws error * @param variable * @param rules */ static attemptAsync(variable: V, rules: AbolishRule): Promise; /** * test a variable, returns boolean * @param variable * @param rules */ test(variable: V, rules: AbolishRule | AbolishCompiled): boolean; /** * Static Check * @param variable * @param rules */ static test(variable: V, rules: AbolishRule | AbolishCompiled): boolean; /** * Checks a variable Asynchronously * @param variable * @param rules */ testAsync(variable: V, rules: AbolishRule): Promise; /** * Static Check Async * @param variable * @param rules */ static testAsync(variable: V, rules: AbolishRule): Promise; /** * Compile a input * @param schema * @param CustomAbolish */ static compileObject(schema: S, CustomAbolish?: TypeOfAbolishOrInstance): AbolishCompiledObject; /** * Compile for a variable * @param rule * @param CustomAbolish */ static compile(rule: AbolishRule, CustomAbolish?: TypeOfAbolishOrInstance): AbolishCompiled; } export type TypeOfAbolishOrInstance = typeof Abolish | InstanceType; /** * Check if a variable can be considered as an Abolish Class * @param $class */ export declare function isAbolishClass($class: any): boolean; /** * Check if a variable can be considered as an Abolish Instance * @param instance */ export declare function isAbolishInstance(instance: any): boolean; export default Abolish;