Questions
5 of 29
1What is a pipe in NestJS and what are its two primary uses?
2How does ValidationPipe work with class-validator and class-transformer in NestJS?
3What is the difference between applying a pipe at the param level vs handler level vs globally in NestJS?
4How do you write a custom pipe for parsing and validating a MongoDB ObjectId param in NestJS?
5What are all the built-in pipes NestJS ships with?
6What is class-transformer and how does it complement class-validator in NestJS?
7How do you write a custom pipe that sanitizes a string input (trim and lowercase) in NestJS?
8How do you write a pipe that uses metatype to skip validation for primitive types the same way ValidationPipe does?
9What are the two ways to register a global pipe in NestJS and what is the difference?
10What are all the significant ValidationPipe options and what does each do in NestJS?
11How do you unit test a custom pipe in NestJS?
12Can a pipe be asynchronous in NestJS and how do you implement one?
13How do you write an async custom validator that checks uniqueness against a database in NestJS?
14How do you validate arrays and conditional fields with class-validator in NestJS?
15How do you use validation groups with class-validator to apply different rules for create vs update operations in NestJS?
16What does @Exclude() and @Expose() do and how do you use them to strip sensitive fields from responses?
17What is the excludeExtraneousValues option in class-transformer and how does it differ from whitelist in ValidationPipe?
18How do you make a custom pipe configurable by accepting constructor options in NestJS?
19How do you customise the error response format produced by ValidationPipe in NestJS?
20How do you handle file upload validation with ParseFilePipe and custom file validators in NestJS?
21What interface must a custom pipe implement and what does the transform() method receive?
22What is the difference between a transformation pipe and a validation pipe in NestJS?
23How do you pass options to a built-in pipe like ParseIntPipe or ParseUUIDPipe in NestJS?
24What is class-validator and how does it integrate with NestJS ValidationPipe?
25What is the @ValidateNested() decorator and when must you pair it with @Type()?
26How do you write a custom class-validator decorator in NestJS?
27What does the @Transform() decorator do in class-transformer and when should you use it?
28How does @Type() interact with discriminated unions and polymorphic DTOs in class-transformer?
29How do you write a pipe that validates and parses a date string from a route parameter in NestJS?
05 / 29

What are all the built-in pipes NestJS ships with?

Difficulty: 5/10
validation, transformation, global pipes

NestJS ships with nine built-in pipes: ValidationPipe, ParseIntPipe, ParseFloatPipe, ParseBoolPipe, ParseArrayPipe, ParseUUIDPipe, ParseEnumPipe, DefaultValuePipe, and ParseFilePipe. Each handles a specific transformation or validation concern.

All nine built-in pipes:
  1. 1

    ValidationPipe — validates DTOs using class-validator; the most commonly used pipe.

  2. 2

    ParseIntPipe — converts a string to an integer; throws 400 if not parseable.

  3. 3

    ParseFloatPipe — converts a string to a float.

  4. 4

    ParseBoolPipe — converts 'true'/'false' strings to boolean.

  5. 5

    ParseArrayPipe — parses a comma-separated string or JSON array string into an array with optional per-item pipe.

  6. 6

    ParseUUIDPipe — validates that a string is a valid UUID (v3, v4, or v5 configurable).

  7. 7

    ParseEnumPipe — validates that a value belongs to a given TypeScript enum.

  8. 8

    DefaultValuePipe — substitutes a fallback value when the input is undefined or null.

  9. 9

    ParseFilePipe — validates uploaded files by size and MIME type.

ParseArrayPipe with per-item transformation

Scenario Questions

0-2 years experience

  1. 1You need to ensure that a route parameter `id` is parsed as an integer before it reaches the controller method. Which built‑in pipe would you use and how would you apply it?
  2. 2If you add the `ParseBoolPipe` to a query parameter expecting a boolean, what happens when the client sends the string `'yes'`? How does Nest handle the conversion or error?

2-5 years experience

  1. 1Your team added `ValidationPipe` globally, but a new endpoint that accepts a file upload is now failing validation unexpectedly. Walk me through how you would debug the issue and decide whether to keep the global pipe or override it.
  2. 2When using `ParseIntPipe` on a DTO property, you notice that certain large numbers are being truncated. Explain why this occurs and what alternative built‑in pipe or configuration you could use to handle big integers.

5-8 years experience

  1. 1In a high‑traffic microservice we need to validate incoming JSON payloads without sacrificing latency. How would you evaluate the performance impact of the built‑in `ValidationPipe` versus a custom lightweight pipe, and what trade‑offs would you consider?
  2. 2Our monorepo contains dozens of NestJS services, each using different combinations of built‑in pipes. Describe a strategy to standardize pipe usage across services while allowing service‑specific overrides, and how you’d enforce it.

8+ years experience

  1. 1We are migrating a legacy codebase that manually parses and validates request data to NestJS. How would you design a migration plan that leverages the built‑in pipes to improve consistency, and what risks or edge cases would you watch for during the rollout?
  2. 2As the architecture lead, you need to define a policy for when to use Nest’s built‑in pipes versus custom pipes across the organization. What criteria would you set, and how would you balance developer productivity, security, and maintainability?

Follow-up Questions

  • Can you show the decorator syntax you’d use to attach that pipe?
  • What HTTP response does Nest send when a built‑in pipe validation fails?
  • How would you customize the error messages emitted by ValidationPipe?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.