import type Abolish from "./Abolish"; import type AbolishError from "./AbolishError"; import type ObjectModifier from "./ObjectModifier"; /** * ValidationError * @description * Result returned by to validate object */ export type ValidationError = { code: string; key: string; type: "internal" | "validator"; message: string; validator: string; data: any; }; export type $skipRule = boolean | ((value: any, data: Record) => boolean); export type $errorRule = string | ((e: Pick & { value: any; }) => string); export type $errorsRule = Record; /** * ValidationResult * @description * Result returned by to validate object */ export type ValidationResult = [error: ValidationError | undefined, validated: T]; export type AbolishValidatorFunctionResult = boolean | AbolishError | void; export type AbolishValidatorFunctionHelper = { error: (message: string, data?: any) => AbolishError; modifier: ObjectModifier; abolish: Abolish; }; export type AbolishValidatorFunction = (value: any, option: any, helpers: AbolishValidatorFunctionHelper) => AbolishValidatorFunctionResult | Promise; export type AbolishInlineValidator = (value: any, helpers: AbolishValidatorFunctionHelper) => boolean | AbolishError | Promise; /** * Validator * @description * A new validator type */ export interface AbolishValidator { name: string; description?: string | string[]; validator: AbolishValidatorFunction; error?: string; isAsync?: true; } export interface AbolishAsyncValidator extends Omit { isAsync: true; } export type AbolishRule = string | string[] | Record | AbolishRule[]; export type AbolishSchema = Record> = Record;