Recall & Review
beginner
What is a custom pipe in NestJS?
A custom pipe in NestJS is a class that implements the PipeTransform interface to transform or validate data before it reaches the route handler.Click to reveal answer
beginner
Which method must be implemented in a custom pipe class?
The method
transform(value: any, metadata: ArgumentMetadata) must be implemented to define how the input data is processed.Click to reveal answer
beginner
How do you apply a custom pipe to a route handler parameter?
You apply a custom pipe by adding it as an argument decorator, for example:
@Param('id', new MyCustomPipe()) id: string.Click to reveal answer
intermediate
What happens if a custom pipe throws an exception during transformation?
If a custom pipe throws an exception, NestJS stops the request processing and sends an error response to the client.
Click to reveal answer
intermediate
Why use custom pipes instead of handling validation inside controllers?
Custom pipes keep controllers clean by separating validation and transformation logic, making code easier to maintain and reuse.
Click to reveal answer
What interface must a custom pipe implement in NestJS?
✗ Incorrect
Custom pipes must implement the PipeTransform interface to define the transform method.
Where is the transform method called in a custom pipe?
✗ Incorrect
The transform method runs before the route handler to process incoming data.
How do you apply a custom pipe globally in NestJS?
✗ Incorrect
Global pipes are applied with app.useGlobalPipes() in the main bootstrap file.
What should a custom pipe return if the input is valid?
✗ Incorrect
If valid, the pipe returns the transformed or original value to continue processing.
Which decorator is commonly used to apply a pipe to a route parameter?
✗ Incorrect
Pipes can be applied to @Param, @Body, and @Query decorators to validate or transform data.
Explain how to create and use a custom pipe in NestJS.
Think about how data flows before reaching the controller.
You got /4 concepts.
Describe the benefits of using custom pipes for validation and transformation.
Consider how code organization improves with pipes.
You got /4 concepts.