@@ -8,14 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
88var __metadata = ( this && this . __metadata ) || function ( k , v ) {
99 if ( typeof Reflect === "object" && typeof Reflect . metadata === "function" ) return Reflect . metadata ( k , v ) ;
1010} ;
11- var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
12- return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
13- function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
14- function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
15- function step ( result ) { result . done ? resolve ( result . value ) : new P ( function ( resolve ) { resolve ( result . value ) ; } ) . then ( fulfilled , rejected ) ; }
16- step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
17- } ) ;
18- } ;
1911var __rest = ( this && this . __rest ) || function ( s , e ) {
2012 var t = { } ;
2113 for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) && e . indexOf ( p ) < 0 )
@@ -42,23 +34,21 @@ let ValidationPipe = class ValidationPipe {
4234 classValidator = loadPkg ( 'class-validator' ) ;
4335 classTransformer = loadPkg ( 'class-transformer' ) ;
4436 }
45- transform ( value , metadata ) {
46- return __awaiter ( this , void 0 , void 0 , function * ( ) {
47- const { metatype } = metadata ;
48- if ( ! metatype || ! this . toValidate ( metadata ) ) {
49- return value ;
50- }
51- const entity = classTransformer . plainToClass ( metatype , value ) ;
52- const errors = yield classValidator . validate ( entity , this . validatorOptions ) ;
53- if ( errors . length > 0 ) {
54- throw new index_1 . BadRequestException ( errors ) ;
55- }
56- return this . isTransformEnabled
57- ? entity
58- : Object . keys ( this . validatorOptions ) . length > 0
59- ? classTransformer . classToPlain ( entity )
60- : value ;
61- } ) ;
37+ async transform ( value , metadata ) {
38+ const { metatype } = metadata ;
39+ if ( ! metatype || ! this . toValidate ( metadata ) ) {
40+ return value ;
41+ }
42+ const entity = classTransformer . plainToClass ( metatype , value ) ;
43+ const errors = await classValidator . validate ( entity , this . validatorOptions ) ;
44+ if ( errors . length > 0 ) {
45+ throw new index_1 . BadRequestException ( errors ) ;
46+ }
47+ return this . isTransformEnabled
48+ ? entity
49+ : Object . keys ( this . validatorOptions ) . length > 0
50+ ? classTransformer . classToPlain ( entity )
51+ : value ;
6252 }
6353 toValidate ( metadata ) {
6454 const { metatype, type } = metadata ;
0 commit comments