@@ -9,7 +9,7 @@ export const useValidationPipe = {
9
9
return {
10
10
ClassDeclaration : ( node : ClassDeclaration ) => {
11
11
const classUsePipes = getDecoratorByName ( node , 'UsePipes' ) ;
12
- validationPipeInClass = hasNewExprValidationPipe ( classUsePipes ) ;
12
+ validationPipeInClass = hasExprValidationPipe ( classUsePipes ) ;
13
13
} ,
14
14
'ClassDeclaration:exit' : ( ) => {
15
15
validationPipeInClass = false ;
@@ -23,11 +23,11 @@ export const useValidationPipe = {
23
23
return ;
24
24
}
25
25
const body = getDecoratorByName ( param , 'Body' ) ;
26
- if ( hasNewExprValidationPipe ( body ) ) {
26
+ if ( hasExprValidationPipe ( body ) ) {
27
27
return ;
28
28
}
29
29
const usePipes = getDecoratorByName ( node , 'UsePipes' ) ;
30
- if ( hasNewExprValidationPipe ( usePipes ) ) {
30
+ if ( hasExprValidationPipe ( usePipes ) ) {
31
31
return ;
32
32
}
33
33
const { typeAnnotation } = param as any ;
@@ -39,10 +39,13 @@ export const useValidationPipe = {
39
39
}
40
40
} ;
41
41
42
- function hasNewExprValidationPipe ( node ) {
42
+ function hasExprValidationPipe ( node ) {
43
43
if ( ! node ) {
44
44
return false ;
45
45
}
46
46
return ( node . expression as CallExpression ) . arguments
47
- . some ( argument => argument . type === 'NewExpression' && argument . callee . type === 'Identifier' && argument . callee . name === 'ValidationPipe' ) ;
47
+ . some ( argument => {
48
+ return ( argument . type === 'NewExpression' && argument . callee . type === 'Identifier' && argument . callee . name === 'ValidationPipe' )
49
+ || ( argument . type === 'Identifier' && argument . name === 'ValidationPipe' ) ;
50
+ } ) ;
48
51
}
0 commit comments