File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -249,34 +249,33 @@ In the next section, you'll see how we supply the appropriate schema for a given
249249``` typescript 
250250@@filename ()
251251import  { PipeTransform , ArgumentMetadata , BadRequestException  } from  ' @nestjs/common'  ;
252- import  { ZodObject  } from  ' zod'  ;
252+ import  { ZodSchema    } from  ' zod'  ;
253253
254254export  class  ZodValidationPipe  implements  PipeTransform  {
255-   constructor (private  schema :  ZodObject < any > ) {}
255+   constructor (private  schema :  ZodSchema ) {}
256256
257257  transform(value :  unknown , metadata :  ArgumentMetadata ) {
258258    try  {
259-       this .schema .parse (value );
259+       const   parsedValue =  this .schema .parse (value );
260+       return  parsedValue ;
260261    } catch  (error ) {
261262      throw  new  BadRequestException (' Validation failed'  );
262263    }
263-     return  value ;
264264  }
265265}
266266@@switch 
267267import  { BadRequestException  } from  ' @nestjs/common'  ;
268- import  { ZodObject  } from  ' zod'  ;
269268
270- export  class  ZodValidationPip  {
269+ export  class  ZodValidationPipe  {
271270  constructor (private  schema ) {}
272271
273272  transform(value , metadata ) {
274273    try  {
275-       this .schema .parse (value );
274+       const   parsedValue =  this .schema .parse (value );
275+       return  parsedValue ;
276276    } catch  (error ) {
277277      throw  new  BadRequestException (' Validation failed'  );
278278    }
279-     return  value ;
280279  }
281280}
282281
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments