Joi for Node: Exploring Javascript Object Schema Validation

Adopt Object Schema Validation for your NodeJS Projects

Ross Bulat
10 min readOct 27, 2018

Object validation server side is a necessity for public web services — the realisation of this necessity became Joi — the most widely adopted package for object schema descriptions and validation. Joi allows us to create blueprints of Javascript objects that ensure that we process and ultimately accept accurate data. This article will explore the use cases of Joi and how to apply it to your Node projects.

Joi for the browser? No — use Yup Instead

Joi was designed for server-side scripts in mind, and in my opinion should be strictly kept on the server side. If you are looking for object validation on the front end in the browser, you can either adopt joi-browser, or an entirely different package altogether. Joi browser is the Joi community’s answer to browser-based validation, which contains the original idea of Joi combined with polyfills to ensure compatibility with ES6 standards in older browsers.

However, this adds additional size to your JS bundles and workarounds which were not considered at the fundamental conceptual level of Joi. Therefore, for the browser, Yup is a much preferred solution: the package is leaner and specifically designed for…

--

--

Ross Bulat
Ross Bulat

Written by Ross Bulat

Programmer and Author. @ Parity Technologies, JKRB Investments