Skip to content

Commit a0b85d8

Browse files
authored
Merge pull request #14 from issfront/master
feat(typescript类型支持): 添加ts的定义文件
2 parents ec22f74 + 9596767 commit a0b85d8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

types/index.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
declare module "we-validator" {
2+
type Rule = Function | RegExp;
3+
type RuleOption = { rule: Rule; message: string };
4+
type Options = {
5+
rules: object,
6+
messages: object,
7+
onMessage?: Function,
8+
multiple?: boolean
9+
}
10+
class WeValidator {
11+
constructor(options: Options);
12+
static RULES: object;
13+
static addRule(ruleName: string, ruleOption: RuleOption): void;
14+
static checkValue(ruleName: string, value: string, param: any, skip: boolean): void;
15+
options: Options;
16+
required: Function;
17+
checkData(data: object, onMessage?: Function, showMessage?: boolean, fieldMap?: object): void;
18+
checkFields(data: object, onMessage?: Function, showMessage?: boolean): void;
19+
isValid(data: object, fields: Array<string>): boolean;
20+
addRules(options: Options): void;
21+
removeRules(fields: Array<string>): void;
22+
}
23+
export = WeValidator
24+
}
25+

0 commit comments

Comments
 (0)