Implement PipeTransform with string generic types, guard against non-string inputs with a typeof check, and return the sanitized value. Apply at param level for targeted sanitization or at handler level with @UsePipes() for all string arguments of that route.
Always guard non-target types with typeof or metadata.metatype checks — pass them through unchanged.
Use PipeTransform<Input, Output> generics to make the transformation contract explicit.
Param-level application is the most precise — only the targeted argument is processed.
Handler-level @UsePipes() applies to all arguments — useful for bulk sanitization.
Stateless pipes (no injected services) can be used as class references without new.
Can you walk me through how you'd implement a NestJS pipe that trims whitespace and lowercases a string coming from a request body?
If you applied your pipe to a DTO property that sometimes receives null, what would happen and how would you handle it?
Where would you register this pipe if you only want it to affect a single controller method?
Suppose you added this sanitizing pipe globally, but some endpoints expecting case‑sensitive strings (like API keys) are now failing. How would you troubleshoot and resolve the issue?
Your team wants the pipe to also reject strings that contain prohibited characters. How would you extend the pipe while keeping it reusable?
During testing, the pipe seems to be skipped when validation fails earlier in the pipeline. Explain why that might happen and how to ensure it runs.
When scaling the service to handle thousands of requests per second, what performance considerations would you evaluate for a globally applied sanitizing pipe?
How would you design a strategy to version your custom pipe so that older clients can continue using the previous sanitization behavior while new clients get the updated logic?
If multiple modules need slightly different sanitization rules, how would you structure your pipe architecture to avoid code duplication and maintain consistency?
Across several microservices, you need consistent string sanitization but each service uses different NestJS versions. How would you create a shared library for the pipe, handling compatibility and deployment?
Your organization is moving from a monolith to a distributed system and wants to enforce input sanitization centrally. Discuss the trade‑offs between implementing the pipe at the API gateway versus inside each NestJS service.
What governance processes would you put in place to ensure any new custom pipes meet security, testing, and performance standards across teams?