UNPKG

@berish/validate

Version:

Validation of complex objects with support for validation maps, rules and decorators

11 lines (10 loc) 757 B
import { IValidateRule, IRuleObject, IRuleObjectBody, IRuleObjectFlag, IRuleErrorTextResult } from './types'; import { IRuleFlag } from './createRuleFlag'; export declare const SYMBOL_ERROR_TEXT_DEFAULT: unique symbol; export interface ICreateRuleParams<Body extends any[]> { name?: string; conditionSync?: (obj: IRuleObject & IRuleObjectBody<Body>) => boolean | IRuleFlag; conditionAsync?: (obj: IRuleObject & IRuleObjectBody<Body>) => boolean | IRuleFlag | Promise<boolean | IRuleFlag>; errorText?: (obj: IRuleObject & IRuleObjectBody<Body> & IRuleObjectFlag) => IRuleErrorTextResult | typeof SYMBOL_ERROR_TEXT_DEFAULT | void; } export declare function createRule<Body extends any[]>(params: ICreateRuleParams<Body>): IValidateRule<Body>;