Pipes and Validation — Basics · NestJS

Validate request bodies with a DTO class and ValidationPipe, strip unknown fields, and let ParseIntPipe turn a route parameter into a number or a 400.

What you will learn

Read the theory for Pipes and Validation

All Basics lessons

All NestJS courses

loading types…

What you'll learn

  • Describe a request body with a DTO class and class-validator rules, and read the messages the rules generate
  • Enable ValidationPipe once for the whole application, with whitelist stripping unknown fields
  • Convert a route parameter with ParseIntPipe and get a 400 for input that is not a number