InterviewBuddy
All interview questions

What is the purpose of a pipe?

Beginner

Answer

A pipe transforms or validates data before it reaches a controller method. Nest can apply pipes to parameters, routes, controllers, or globally.

Explanation

Validation should reject unexpected input before business logic runs. Database constraints still protect persistent invariants.

Example

@Param("id", ParseIntPipe) id: number