Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
Validation Pipes in NestJS : @UsePipes(ValidationPipe) or @UsePipes(new ValidationPipe())?

I previously saw these two syntaxes for UsePipes Decorator in NestJS tutorials:

@UsePipes(ValidationPipe) 
@UsePipes(new ValidationPipe())

From what I understand, ValidationPipe is a class itself, where new ValidationPipe() just works as in all object-oriented languages and creates a new instance of ValidationPipe.

What should I use ? What is the difference ? Is there any special usage where one if preferable to another ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Both work fine as is. If you need to pass any options to the pipe though, you should use the new ValidationPipe(). Otherwise, Nest will see the pipe is a class reference, not an instance, and create the instance to be used.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!