hapi — Reply Custom View for Failed Validations

Validations are built into hapi’s core and the framework has first class support for Joi, the schema validation framework. The overall validation setup for individual routes is very convenient and expressive, you’ll see that in a minute.

The default behavior for failed validations is to send proper error data back to the client, as JSON. In case you have a styled form on your website, the user puts all the data, sends it to your server, and the response is an error text in JSON format that rips the user completely out of context because there’s no nicely styled design anymore.

This tutorial walks you through the hapi setup to render a selected view in case of failed validations.

hapi Series Overview

Continue reading

University Enrollment Required

Future Students benefit from value packed videos and tutorials.

Enroll to receive exclusive content or sign in if you’re already a Future Student.

Enroll me for $15/mo

Explore the Library

Find interesting tutorials and solutions for your problems.