O'Reilly logo

hapi.js in Action by Matt Harrison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Validation with Joi

This chapter covers

  • Working with Joi
  • Adding validation to hapi.js apps
  • Customizing validation errors
  • Consuming and presenting validation errors

Humans often make mistakes, and as a result the systems we create need to be prepared for misuse. Validation is an essential part of almost every system we use in our daily lives. An example of such a system is a snack vending machine.

A vending machine has several inputs that it needs to validate. If any one input doesn’t match its expectations, the machine will halt normal functioning and give feedback to the user on what went wrong. For instance, if you place a foreign coin in the slot, the machine will reject the coin, spitting it out into the coin return tray, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required