Skip to content

Commit 8032fe7

Browse files
author
Markus Peloso
committed
Merge from master.
2 parents 6524d47 + 7acdb48 commit 8032fe7

File tree

15 files changed

+296
-225
lines changed

15 files changed

+296
-225
lines changed

.gitignore

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@ _infrastructure/tests/build
2828
.idea
2929
*.iml
3030
*.js.map
31-
32-
#decimal.js
33-
!decimal.js
34-
35-
#egg.js
36-
!egg.js
37-
38-
#rx.js
39-
!rx.js
40-
41-
#zip.js
42-
!zip.js
31+
!*.js/
4332

4433
node_modules
4534

dojo/dojo.d.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ declare module dojo {
927927
*
928928
*
929929
*/
930-
class __Promise extends dojo.promise.Promise {
930+
class __Promise implements dojo.promise.Promise<any> {
931931
constructor();
932932
/**
933933
* A promise resolving to an object representing
@@ -988,19 +988,19 @@ declare module dojo {
988988
* @param errback OptionalCallback to be invoked when the promise is rejected.Receives the rejection error.
989989
* @param progback OptionalCallback to be invoked when the promise emits a progressupdate. Receives the progress update.
990990
*/
991-
then(callback?: Function, errback?: Function, progback?: Function): dojo.promise.Promise;
991+
then(callback?: Function, errback?: Function, progback?: Function): dojo.promise.Promise<any>;
992992
/**
993993
*
994994
*/
995995
toString(): String;
996996
/**
997997
*
998998
*/
999-
trace(): dojo.promise.Promise;
999+
trace(): dojo.promise.Promise<any>;
10001000
/**
10011001
*
10021002
*/
1003-
traceRejected(): dojo.promise.Promise;
1003+
traceRejected(): dojo.promise.Promise<any>;
10041004
}
10051005
/**
10061006
* Permalink: http://dojotoolkit.org/api/1.9/dojo/request/default.html
@@ -1590,7 +1590,7 @@ declare module dojo {
15901590
* @param listener
15911591
* @param dontFix
15921592
*/
1593-
once(target: any, type: any, listener: any, dontFix: any): any;
1593+
once(target: any, type: any, listener: any, dontFix?: any): any;
15941594
/**
15951595
*
15961596
* @param target
@@ -1783,7 +1783,7 @@ declare module dojo {
17831783
* @param errback OptionalCallback to be invoked when the promise is rejected.
17841784
* @param progback OptionalCallback to be invoked when the promise emits a progress update.
17851785
*/
1786-
interface when{(valueOrPromise: any, callback?: Function, errback?: Function, progback?: Function): void}
1786+
interface when { <T, U>(value: T|dojo.promise.Promise<T>, callback: dojo.promise.Callback<T, U>, errback?: any, progback?: any): U|dojo.promise.Promise<U> }
17871787
/**
17881788
* Permalink: http://dojotoolkit.org/api/1.9/dojo/DeferredList.html
17891789
*
@@ -1822,7 +1822,7 @@ declare module dojo {
18221822
/**
18231823
*
18241824
*/
1825-
"promise": dojo.promise.Promise;
1825+
"promise": dojo.promise.Promise<any>;
18261826
/**
18271827
* Inform the deferred it may cancel its asynchronous operation.
18281828
* Inform the deferred it may cancel its asynchronous operation.
@@ -1863,7 +1863,7 @@ declare module dojo {
18631863
* @param update The progress update. Passed to progbacks.
18641864
* @param strict OptionalIf strict, will throw an error if the deferred has alreadybeen fulfilled and consequently no progress can be emitted.
18651865
*/
1866-
progress(update: any, strict: boolean): dojo.promise.Promise;
1866+
progress(update: any, strict: boolean): dojo.promise.Promise<any>;
18671867
/**
18681868
* Reject the deferred.
18691869
* Reject the deferred, putting it in an error state.
@@ -1879,7 +1879,7 @@ declare module dojo {
18791879
* @param value The result of the deferred. Passed to callbacks.
18801880
* @param strict OptionalIf strict, will throw an error if the deferred has alreadybeen fulfilled and consequently cannot be resolved.
18811881
*/
1882-
resolve(value: any, strict?: boolean): dojo.promise.Promise;
1882+
resolve(value: any, strict?: boolean): dojo.promise.Promise<any>;
18831883
/**
18841884
* Add new callbacks to the deferred.
18851885
* Add new callbacks to the deferred. Callbacks can be added
@@ -1889,7 +1889,7 @@ declare module dojo {
18891889
* @param errback OptionalCallback to be invoked when the promise is rejected.Receives the rejection error.
18901890
* @param progback OptionalCallback to be invoked when the promise emits a progressupdate. Receives the progress update.
18911891
*/
1892-
then(callback: Function, errback: Function, progback: Function): dojo.promise.Promise;
1892+
then(callback: Function, errback: Function, progback: Function): dojo.promise.Promise<any>;
18931893
/**
18941894
*
18951895
*/
@@ -9119,7 +9119,7 @@ declare module dojo {
91199119
* @param errback OptionalCallback to be invoked when the promise is rejected.
91209120
* @param progback OptionalCallback to be invoked when the promise emits a progress update.
91219121
*/
9122-
when(valueOrPromise: any, callback: Function, errback: Function, progback: Function): dojo.promise.Promise;
9122+
when(valueOrPromise: any, callback: Function, errback: Function, progback: Function): dojo.promise.Promise<any>;
91239123
/**
91249124
* signal fired by impending window destruction. You may use
91259125
* dojo.addOnWIndowUnload() or dojo.connect() to this method to perform
@@ -16050,7 +16050,7 @@ declare module dojo {
1605016050
*
1605116051
* @param objectOrArray OptionalThe promise will be fulfilled with a list of results if invoked with anarray, or an object of results when passed an object (using the samekeys). If passed neither an object or array it is resolved with anundefined value.
1605216052
*/
16053-
interface all{(objectOrArray?: Object): void}
16053+
interface all{<T>(value: Promise<T>[]): Promise<T[]>}
1605416054
/**
1605516055
* Permalink: http://dojotoolkit.org/api/1.9/dojo/promise/all.html
1605616056
*
@@ -16063,7 +16063,7 @@ declare module dojo {
1606316063
*
1606416064
* @param objectOrArray OptionalThe promise will be fulfilled with a list of results if invoked with anarray, or an object of results when passed an object (using the samekeys). If passed neither an object or array it is resolved with anundefined value.
1606516065
*/
16066-
interface all{(objectOrArray?: any[]): void}
16066+
interface all{(value: Object): Promise<any>}
1606716067
/**
1606816068
* Permalink: http://dojotoolkit.org/api/1.9/dojo/promise/first.html
1606916069
*
@@ -16107,6 +16107,11 @@ declare module dojo {
1610716107
* @param Deferred
1610816108
*/
1610916109
interface instrumentation{(Deferred: any): void}
16110+
16111+
interface Callback<T, U> {
16112+
(arg: T): U|Promise<U>;
16113+
}
16114+
1611016115
/**
1611116116
* Permalink: http://dojotoolkit.org/api/1.9/dojo/promise/Promise.html
1611216117
*
@@ -16115,15 +16120,14 @@ declare module dojo {
1611516120
* instances of this class.
1611616121
*
1611716122
*/
16118-
class Promise {
16119-
constructor();
16123+
interface Promise<T> {
1612016124
/**
1612116125
* Add a callback to be invoked when the promise is resolved
1612216126
* or rejected.
1612316127
*
1612416128
* @param callbackOrErrback OptionalA function that is used both as a callback and errback.
1612516129
*/
16126-
always(callbackOrErrback: Function): any;
16130+
always<U>(callbackOrErrback: Callback<any, U>): Promise<U>;
1612716131
/**
1612816132
* Inform the deferred it may cancel its asynchronous operation.
1612916133
* Inform the deferred it may cancel its asynchronous operation.
@@ -16160,7 +16164,7 @@ declare module dojo {
1616016164
*
1616116165
* @param errback OptionalCallback to be invoked when the promise is rejected.
1616216166
*/
16163-
otherwise(errback: Function): any;
16167+
otherwise<U>(errback: Callback<any, U>): Promise<U>;
1616416168
/**
1616516169
* Add new callbacks to the promise.
1616616170
* Add new callbacks to the deferred. Callbacks can be added
@@ -16170,7 +16174,7 @@ declare module dojo {
1617016174
* @param errback OptionalCallback to be invoked when the promise is rejected.Receives the rejection error.
1617116175
* @param progback OptionalCallback to be invoked when the promise emits a progressupdate. Receives the progress update.
1617216176
*/
16173-
then(callback: Function, errback?: Function, progback?: Function): dojo.promise.Promise;
16177+
then<U>(callback: Callback<T, U>, errback?: Callback<any, U>, progback?: Callback<any, U>): Promise<U>;
1617416178
/**
1617516179
*
1617616180
*/
@@ -16184,7 +16188,7 @@ declare module dojo {
1618416188
* to handle traces.
1618516189
*
1618616190
*/
16187-
trace(): dojo.promise.Promise;
16191+
trace(): Promise<T>;
1618816192
/**
1618916193
* Trace rejection of the promise.
1619016194
* Tracing allows you to transparently log progress,
@@ -16194,7 +16198,7 @@ declare module dojo {
1619416198
* to handle traces.
1619516199
*
1619616200
*/
16197-
traceRejected(): dojo.promise.Promise;
16201+
traceRejected(): Promise<T>;
1619816202
}
1619916203
/**
1620016204
* Permalink: http://dojotoolkit.org/api/1.9/dojo/promise/tracer.html
@@ -17467,7 +17471,7 @@ declare module dojo {
1746717471
*
1746817472
* @param results The result set as an array, or a promise for an array.
1746917473
*/
17470-
interface QueryResults{(results: dojo.promise.Promise): void}
17474+
interface QueryResults{(results: dojo.promise.Promise<any>): void}
1747117475
/**
1747217476
* Permalink: http://dojotoolkit.org/api/1.9/dojo/store/util/SimpleQueryEngine.html
1747317477
*
@@ -20456,7 +20460,7 @@ declare module dojo {
2045620460
* @param value the number to be formatted
2045720461
* @param options OptionalAn object with the following properties:pattern (String, optional): override formatting patternwith this string. Default value is based on locale. Overriding this property will defeatlocalization. Literal characters in patterns are not supported.type (String, optional): choose a format type based on the locale from the following:decimal, scientific (not yet supported), percent, currency. decimal by default.places (Number, optional): fixed number of decimal places to show. This overrides anyinformation in the provided pattern.round (Number, optional): 5 rounds to nearest .5; 0 rounds to nearest whole (default). -1means do not round.locale (String, optional): override the locale used to determine formatting rulesfractional (Boolean, optional): If false, show no decimal places, overriding places and pattern settings.
2045820462
*/
20459-
format(value: number, options: Object): any;
20463+
format(value: number, options?: Object): any;
2046020464
/**
2046120465
* Convert a properly formatted string to a primitive Number, using
2046220466
* locale-specific settings.
@@ -20782,7 +20786,7 @@ declare module dojo {
2078220786
* @param root OptionalA default starting root node from which to start the parsing. Can beomitted, defaulting to the entire document. If omitted, the optionsobject can be passed in this place. If the options object has arootNode member, that is used.
2078320787
* @param options a kwArgs options object, see parse() for details
2078420788
*/
20785-
scan(root: HTMLElement, options: Object): dojo.promise.Promise;
20789+
scan(root: HTMLElement, options: Object): dojo.promise.Promise<any>;
2078620790
}
2078720791
/**
2078820792
* Permalink: http://dojotoolkit.org/api/1.9/dojo/regexp.html
@@ -24419,7 +24423,7 @@ declare module dojo {
2441924423
* @param errback OptionalCallback to be invoked when the promise is rejected.
2442024424
* @param progback OptionalCallback to be invoked when the promise emits a progress update.
2442124425
*/
24422-
when(valueOrPromise: any, callback: Function, errback: Function, progback: Function): dojo.promise.Promise;
24426+
when(valueOrPromise: any, callback: Function, errback: Function, progback: Function): dojo.promise.Promise<any>;
2442324427
/**
2442424428
* signal fired by impending window destruction. You may use
2442524429
* dojo.addOnWIndowUnload() or dojo.connect() to this method to perform
@@ -28268,8 +28272,8 @@ declare module "dojo/promise/tracer" {
2826828272
export=exp;
2826928273
}
2827028274
declare module "dojo/promise/Promise" {
28271-
var exp: typeof dojo.promise.Promise
28272-
export=exp;
28275+
interface Promise<T> extends dojo.promise.Promise<T> { }
28276+
export = Promise;
2827328277
}
2827428278
declare module "dojo/rpc/JsonpService" {
2827528279
var exp: typeof dojo.rpc.JsonpService

express-validator/express-validator-tests.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,33 @@
55
import util = require('util')
66
import express = require('express')
77
import expressValidator = require('express-validator')
8-
var app = express()
8+
var app = express();
99

1010
app.use(expressValidator());
1111

12-
app.post('/:urlparam', function(req: expressValidator.ValidatedRequest, res: express.Response) {
12+
app.post('/:urlparam', function(req: express.Request, res: express.Response) {
1313

1414
// checkBody only checks req.body; none of the other req parameters
1515
// Similarly checkParams only checks in req.params (URL params) and
1616
// checkQuery only checks req.query (GET params).
1717
req.checkBody('postparam', 'Invalid postparam').notEmpty().isInt();
1818
req.checkParams('urlparam', 'Invalid urlparam').isAlpha();
1919
req.checkQuery('getparam', 'Invalid getparam').isInt();
20+
req.checkHeader('testHeader', 'Invalid testHeader').isLowercase().isUppercase();
21+
req.checkFiles('testFiles', 'Invalid testFiles').isUrl();
22+
2023

2124
// OR assert can be used to check on all 3 types of params.
2225
// req.assert('postparam', 'Invalid postparam').notEmpty().isInt();
2326
// req.assert('urlparam', 'Invalid urlparam').isAlpha();
2427
// req.assert('getparam', 'Invalid getparam').isInt();
2528

2629
req.sanitize('postparam').toBoolean();
30+
req.filter('postparam').toBoolean();
2731

2832
var errors = req.validationErrors();
33+
var mappedErrors = req.validationErrors(true);
34+
2935
if (errors) {
3036
res.status(400).send('There have been validation errors: ' + util.inspect(errors));
3137
return;

0 commit comments

Comments
 (0)