Adding Validation Rules to the DTO Class

Learn how to use class-validator decorators to incorporate validation rules into our DTO classes.

Now that we have learned how to use pipes in NestJS, let’s get back to our virtual library. In this section, we’ll use the class-validator decorators in our DTO and ValidationPipe to ensure data integrity in our virtual library.

Adding ValidationPipe in main.ts

Remember what we learned in the lesson on pipes? It’s time to apply it! Update the editor below to set ValidationPipe as a global pipe for our virtual library.

Get hands-on with 1300+ tech skills courses.