Bird
0
0

What is wrong with this code snippet?

medium📝 Debug Q6 of 15
NestJS - Pipes
What is wrong with this code snippet?
@UsePipes(ValidationPipe)
@Get()
getAll() { return [] }
AValidationPipe is not instantiated with 'new'
BPipes cannot be used on GET methods
CMissing @Param decorator for pipe binding
DgetAll method must have parameters to use pipes
Step-by-Step Solution
Solution:
  1. Step 1: Check pipe usage syntax

    Pipes must be instantiated with 'new' keyword when passed to @UsePipes.
  2. Step 2: Identify missing instantiation

    Here, ValidationPipe is passed as a class reference, not an instance.
  3. Final Answer:

    ValidationPipe is not instantiated with 'new' -> Option A
  4. Quick Check:

    Always instantiate pipes with new before binding [OK]
Quick Trick: Always use 'new' when binding pipes with @UsePipes [OK]
Common Mistakes:
  • Passing pipe class instead of instance
  • Thinking pipes can't be used on GET
  • Assuming parameters are required for pipes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes