Nice article taking advantage of the clean validation of Joi. I’m just wondering what if your validation becomes complex? Complex mean, that the value of b is validated by the value of a?

Let’s say you are building out a registration form. You have the basic fields (name, age, phone number).

What if you want to validate for the phone number ONLY if the age is less than 18 years old? If the age is lower than 18, phone number is required else not required. Haven’t looked into the documentation. Any thoughts I missed?

Written by

Improvise, Adapt, Overcome

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store