Skip to content

Commit

Permalink
typescript: add customValidators to the Validator interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavohenke committed Jul 11, 2017
1 parent 817af05 commit a8dde31
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/type-definition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import * as validator from '..'
import * as express from 'express'
const app = express();

// customValidators defined right below
declare module '..' {
export interface Validator {
isAwesomeLib(): Validator;
isAsync(): Validator;
}
}

app.use(validator({
customValidators: {
Expand Down Expand Up @@ -115,6 +122,8 @@ app.use((req: express.Request, res: express.Response, next: express.NextFunction


req.check('param', 'message')
.isAwesomeLib()
.isAsync()
.isEmail().isEmail({ allow_display_name: true, allow_utf8_local_part: true, require_tld: true })
.isURL({
protocols: ['http', 'https', 'ftp'],
Expand Down

0 comments on commit a8dde31

Please sign in to comment.