import { type ValidationContext } from '../../context'; import { type ValidationResult, type ValidationTypes } from '../../types'; import { type IndependentValidationRule } from '../types'; /** * Единые параметры для всех правил */ export type CommonRuleParams = { /** * Функция, позволяющая для каждого правила указать исключение */ exclude?: (value: TValidationType, ctx: ValidationContext) => boolean; }; /** * Функция, которая позволяет определять частную логику для guard */ type RuleExecutor> = (value: TValidationType, ctx: ValidationContext) => ValidationResult; /** * Создает правила валидации, которые можно использовать внутри guard или по отдельности * @param executor - функция, которая позволяет определять частную логику для guard * @param commonParams - единые параметры для всех rule * @example * ```ts * const inn = (params: CommonRuleParams & { message?: string }) => * createRule((value, ctx) => { * if (!isInn(value)) { * return ctx.createError({ code: 'custom error', message: params?.message || 'Неверный ИНН' }); * } * * return undefined; * }, params); * ``` */ export declare const createRule: = {}>(executor: RuleExecutor, commonParams?: CommonRuleParams) => (value: Parameters>[0], prevCtx?: Parameters>[1]) => ReturnType>; export {};