UNPKG

verificator

Version:

Client and server-side validation JavaScript library

38 lines (37 loc) 1.8 kB
import { Store } from 'redux'; import ErrorBag from './ErrorBag'; import Translator from './Translator'; import { IState, Rule, Items, Locale, Messages, CustomLocale } from './types'; export default class Validator { protected _store: Store<IState>; protected _translator: Translator; protected _errors: ErrorBag; protected _listeners: Function[]; protected _rules: Items<Function>; static useLocale(locale?: Locale): void; static extend(name: string, validate: Function): void; constructor(data: Items, rules: Items<string | string[]>, customLocale?: CustomLocale); readonly errors: ErrorBag; isValidating(attribute?: string): boolean; validateAll(): Promise<boolean>; validate(attribute: string): Promise<boolean>; setData(data: Items<any>): this; getData(): Items<any>; getValue(attribute: string, defaultValue?: any): any; setRules(rules: Items<string | string[]>): this; addRules(rules: Items<string | string[]>): this; getRules(): Items<Rule[]>; getPrimaryAttribute(attribute: string): string; subscribe(listener: Function): Function; getRule(attribute: string, target: string | string[]): Rule | null; hasRule(attribute: string, target: string | string[]): boolean; extend(name: string, validate: Function): this; getImplicitAttributes(): Items<string[]>; setCustomMessages(messages?: Messages): this; addCustomMessages(messages?: Messages): this; setAttributeNames(attributes?: Items<string>): this; addAttributeNames(attributes?: Items<string>): this; protected _validateRule(attribute: string, rule: Rule): Promise<boolean>; protected _passesOptionalCheck(attribute: string): boolean; protected _replaceAsterisksInParameters(rule: Rule, attribute: string): any[]; }