import type { $skipRule, AbolishRule, AbolishSchema, AbolishValidatorFunctionResult, ValidationError, ValidationResult } from "./types"; /** * Compiled Validator Type */ export interface CompiledValidator { name: string; option: any; optionString?: string; error: string; async: boolean; errorFn?: (e: Pick & { value: any; }) => string; customError?: boolean; func: (value: any, option: any) => AbolishValidatorFunctionResult | Promise; } /** * Abolish Compiled Object Version. */ export interface AbolishCompiledObject extends AbolishCompiled { isObject: true; } /** * Compiled Rule */ export interface CompiledRule { $skip?: $skipRule; $name?: string; validators: Record; } export declare class AbolishCompiled { /** * Hold Compiled Object */ data: Record; /** * Schema Keys and Included Fields */ fields: string[]; /** * Fields included */ includedFields?: string[]; /** * Allowed Fields when $strict rule is used */ allowedFields?: string[]; /** * If fields has any dot notation set to true */ fieldsHasDotNotation: boolean; /** * Is Object is true, but if a variable is passed, it will return false */ isObject: boolean; /** * if there is an async validator, set to true */ async: boolean; input: AbolishRule | AbolishSchema; /** * Constructor * @param input */ constructor(input: AbolishRule | AbolishSchema); /** * Validate Compiled Schema * @param data */ validateObject>(data: Record): ValidationResult; validateObjectAsync>(data: Record): Promise>; /** * Validate a variable using a variable compiled input * @param variable Variable to validate * @returns */ validateVariable(variable: T): ValidationResult; /** * validateVariable async version * @param variable Variable to validate * @returns */ validateVariableAsync(variable: T): Promise>; validate(value: T): ValidationResult; validateAsync(value: T): Promise>; /** * Get `this.input` as AbolishRule */ getInputRule(): AbolishRule; /** * Get `this.input` as AbolishSchema */ getInputSchema(): AbolishSchema; /** * Change a fields validator option * @param fieldName * @param validatorName * @param option */ setValidatorOption(validatorName: string, option: any, fieldName?: string): this; /** * Copy current compiled instance * This is useful when you want to use the same compiled input for multiple validation * It prevents memory leak */ copy(): this; }