We SPARK Ideas!

JOI Utils

Valentin Duricu

A list of JOI plugins that helps you with validating some special cases like: Timezones, Phone numbers and XSS sanitisation.

Working on applications that receive input data from users will require the data to be validated and sanitized before saving it in the database. As a result, we had to look over tools that ease our work in validating and sanitizing this data.

The best solution we found, for our use cases, was JOI. Why we chose JOI over alternative solutions? Well, first of all because of the possibilities that JOI offers for the validation of standard data types (strings, numbers, booleans, object and array), together with special cases like emails, urls or IP addresses, to name a few. Secondly because of the API exposed to extend the functionality with custom validators. And finaly, because of the available custom validators created by various developers and published on NPM or on Github.

While some of the applications only needed basic validation and sanitization of the data, there were situations where we needed to validate some special cases like: phone numbers, timezones or text fields that should allow the user enter a longer description using markdown, but to disallow usage of code that could be harmful for the person seeing that data. As a result, we developed a series of JOI extensions that helped us perform these tasks:

If you think that our solution helps you, feel free to use it. And if you find a bug with the plugins we listed above give us a ping either on their pages or through our contact page.

Share twitter/ facebook/ copy link
Your link has expired
Success! Check your email for magic link to sign-in.