Skip to content

Commit

Permalink
feat: add index.d.ts (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
brickyang authored and fengmk2 committed Aug 3, 2018
1 parent 27bb8d5 commit cd52050
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
interface CheckHandlerFunc {
(rule: any, value: any): string;
}

interface ValidateError {
code: string;
field?: string;
message: string;
}

declare module 'egg' {
export interface Application {
validator: {
addRule: (type: string, check: RegExp | CheckHandlerFunc) => void;
validate: (rules: any, data: any) => ValidateError[];
};
}

export interface Context {
validate: (rules: any, data: any) => void;
}
}

0 comments on commit cd52050

Please sign in to comment.