API Authentication with Node Part #4 - Server-Side Validation

Опубликовано: 13 Май 2026
на канале: CodeWorkr
21,960
344

In this video, we'll focus on server-side validation. We want to make sure the requests we'll be getting from the clients are going to be validated before we want to use them for anything else, especially before interacting with the database!

Link to repository: https://github.com/eXtremeXR/APIAuthe...

You can find different commits for different videos and reference the code that way. Every video (that's about programming) will have a corresponding commit that's called the same as the video title.

There are a couple of different ways one could do the server-side validation. There is a popular module called "node-validator", and on top of that "express-validator" module as a wrapper.

However, we aren't going to be using those. Instead, we're going to use the module called Joi. Joi is great in a sense that you can describe, say POST request's body, using JSON schema and it keeps everything else nice and tidy.

Because of that, we're going to create our own 'generic-enough' function in this video that will be able to validate any POST's body as long as we provide the adequate schema.

This might not be the most interesting video, however - validation is a crucial part and we want to make sure we are not skipping any steps, but instead we're building this server to be rock-solid.