@@ -139,6 +139,13 @@ describe(``, () => {
139
139
multipleDateValues ?: Date [ ] ;
140
140
}
141
141
142
+ class QueryWhitelistClass {
143
+ @IsArray ( )
144
+ @IsBoolean ( { each : true } )
145
+ @Transform ( value => ( Array . isArray ( value ) ? value . map ( v => v !== 'false' ) : value !== 'false' ) )
146
+ multipleBooleanValues ?: boolean [ ] ;
147
+ }
148
+
142
149
@Controller ( )
143
150
class UserActionParamsController {
144
151
@Get ( '/users' )
@@ -239,6 +246,14 @@ describe(``, () => {
239
246
return `<html><body>hello</body></html>` ;
240
247
}
241
248
249
+ @Get ( '/photos-params-whitelist' )
250
+ getPhotosWithWhitelistQuery (
251
+ @QueryParams ( { validate : { whitelist : true , forbidNonWhitelisted : true } } ) query : QueryWhitelistClass
252
+ ) : string {
253
+ queryParams3 = query ;
254
+ return `<html><body>hello</body></html>` ;
255
+ }
256
+
242
257
@Get ( '/photos-with-required' )
243
258
getPhotosWithIdRequired ( @QueryParam ( 'limit' , { required : true } ) limit : number ) : string {
244
259
queryParamLimit = limit ;
@@ -594,6 +609,14 @@ describe(``, () => {
594
609
expect ( queryParams1 . multipleDateValues ) . toEqual ( [ new Date ( '2017-02-01T01:00:00Z' ) ] ) ;
595
610
} ) ;
596
611
612
+ it ( "@QueryParams should give a proper values from request's query with validate whitelist option on" , async ( ) => {
613
+ expect . assertions ( 3 ) ;
614
+ const response = await axios . get ( '/photos-params-whitelist?multipleBooleanValues=false' ) ;
615
+ expect ( response . status ) . toEqual ( HttpStatusCodes . OK ) ;
616
+ expect ( response . headers [ 'content-type' ] ) . toEqual ( 'text/html; charset=utf-8' ) ;
617
+ expect ( queryParams3 . multipleBooleanValues ) . toEqual ( [ false ] ) ;
618
+ } ) ;
619
+
597
620
it ( "@QueryParams should give a proper values from request's query parameters with nested json" , async ( ) => {
598
621
expect . assertions ( 13 ) ;
599
622
const response = await axios . get (
0 commit comments