The global ValidationPipe

Pipes are the transform-and-validate stage

Decorators on a DTO are just metadata β€” inert until something reads them. That something is a pipe. In Nest, a pipe runs on the argument bound to a handler parameter, and does one of two jobs (often both): transform it (a string "42" into the number 42) or validate it (reject it if it breaks the rules).

The built-in ValidationPipe is the one you wire up once and forget. On every request it takes the raw body, instantiates your DTO class, runs its class-validator decorators, and either hands your handler a clean typed object or throws a 400 Bad Request with the list of failures.

The reframe: you don't validate inside each handler. You register one pipe globally and every DTO in the app is validated the same way, for free.