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, ...

Get hapi.js in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.