vouch

JSON schema validation ... for humans.

Vouch is a layer on top of JSV which provides human-friendly errors and a slightly simpler interface for JSON schema validation.

npm install vouch
var vouch    = require('vouch');
 
vouch({
    input:  input, 
    schema: schema
}, function (err) {
    if (err) return console.log(err);  // Human friendly errors! 
    // Yay! No errors. 
});

The main benefit of vouch is the ability to easily create custom error messages. The included dict.json file will give you the basic idea of how this works in principle, but let's use the following as an example:

var vouch    = require('vouch');
 
vouch({
    input:  input, 
    schema: schema,
    dict:   {
        'maximum': 'Yo! \"__instance__\" is way larger than __detail__!'
    }
}, function (err) {
    if (err) return console.log(err);  // Human friendly errors! 
    // Yay! No errors. 
});

In this instance, an error of type maximum will result in a custom error. The __instance__ and __detail__ variables can be used to inject detail into the resulting error message.

npm test