Conditional Validation with Joi and NodeJS | JavaScript Quick Tip

preview_player
Показать описание
#joi #validation #javascript

In this video, I'll show you how to create a conditional validation schema with Joi for NodeJS. Very useful for validating requests coming into your API! Conditional validation allows you to change the validation rules for one property, based on the value of another. Really cool!

Joi is a really great library for validating objects in JavaScript, I use it in every Node project - go check it out!

Joi Github:

Joi documentation:

I'm Chris Roberts, a freelance software engineer based in the UK:

Follow me on Twitter:

Our gear - click through to support our channel! :)

Camera (Canon M50)

Camera mic (RODE VideoMic Pro)

Camera tripod (Manfrotto Compact tripod):

Voiceover Mic (Blue Yeti)

Chris's dev mouse for PC (Logitech MX Master 3)

Chris's dev keyboard for PC (Logitech MX Keys)

Rob's dev keyboard for Mac (Apple Magic Keyboard)

Rob's dev mouse for Mac (Apple Magic Mouse)
Рекомендации по теме
Комментарии
Автор

Short and sweet, just what I was looking for. Thank you!

mochaonline
Автор

Fantastic video, love the surprise at the end credits, glad I watched to the end. More short tutorials please

robsretrostuff
Автор

Thanks for passing on the knowledge in such a quick and digestible way.

lixiao
Автор

Subbed at the 2:20 mark
Incredibly insightful
Thanks for this brother

DavidWoodMusic
Автор

Very helpful, I was looking for this. Thanks so much.

patrickmwangi
Автор

Great video, but for us newbies, it sure would be nice to see the *route syntax* and how you consumed the schema. Maybe add it to the description?

fromtheburbstothetetons
Автор

any ideas how to validate request body against query params?

AbhinavAbhiVerma
Автор

Hi Robert. Are you able to advise if joi validation handles dot notation? I'm trying to do conditional validation based on parent nested value....so something like when(“upper.levelvalue‘, ...

Davisworth
Автор

Can you chain .when to other .when statements?

JACOBTL