Before we can consider persisting data off to storage, we need to ensure the data is in a known good shape. This means validation. And there is a really nice library that solves this problem very effectively for us.
We will be using the Class Validator library.
This will solve all our validation concerns, and even take care of creating a lovely error object that we can return to our API consumers.
We didn't add this library at the start of our project as there is a touch extra setup required. Let's take care of this now.
Watch video Create a NodeJS API with Koa and TypeScript - #8 - Easy Validation with Class Validator online without registration, duration hours minute second in high quality. This video was added by user Code Review Videos 04 May 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3,355 once and liked it 40 people.