-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.d.ts
51 lines (36 loc) · 1.12 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Schema } from "rsuite/lib/Schema/Schema";
import { CheckResult } from "rsuite/lib/Schema/Type";
interface ErrorMessageFormatter {
(field: string, placeholderValues?: { [key: string]: any }): string;
}
export interface Rule {
check(field: string, value: any, data: any): boolean;
errorMessage: string | ErrorMessageFormatter;
}
interface TypedErrorMessageFormatter {
[type: string]: string | ErrorMessageFormatter;
}
interface Messages {
[rule: string]: string | ErrorMessageFormatter | TypedErrorMessageFormatter;
}
type MessageBag = Messages & {
fields?: {
[field: string]: string;
};
};
type RuleExpression = string;
type RuleType = string | Rule;
interface RulesInput {
[field: string]: RuleExpression | RuleType[];
}
declare interface ValidatorStatic {
make(rules: RulesInput, messages?: MessageBag): ValidatorInstance;
SchemaModel(rules: RulesInput, messages?: MessageBag): Schema;
messages(messages: MessageBag): void;
}
declare interface ValidatorInstance {
getSchemaModel(): Schema;
check(data: any): CheckResult;
}
declare const Validator: ValidatorStatic;
export { Validator };