🦅 NestJS Beginner

What are Pipes in NestJS?

Answer

Pipes are classes that implement the PipeTransform interface and are used for two purposes: transformation (converting input data to the desired type) and validation (validating input and throwing an exception if invalid). Built-in pipes include: ValidationPipe, ParseIntPipe (converts string param to int, throws 400 if not a number), ParseUUIDPipe, ParseBoolPipe, DefaultValuePipe. Apply pipes at parameter level: @Param('id', ParseIntPipe) id: number. Pipes execute after guards and before the route handler. You can create custom pipes for domain-specific transformations or business rule validation.