Validation — Techniques · NestJS

Enforce the API's contract on every route: a global ValidationPipe that strips and refuses unknown properties and transforms payloads, an update DTO derived from the create DTO, and validated arrays in the body and the query string.

What you will learn

Read the theory for Validation

All Techniques lessons

All NestJS courses

loading types…

What you'll learn

  • Register one ValidationPipe for the application and choose whitelist, forbidNonWhitelisted and transform deliberately
  • Derive an update DTO from a create DTO with PartialType so validators are written once
  • Validate a body array and parse a comma-separated query list with ParseArrayPipe