vouch

JSON schema validation ... for humans.

npm install vouch
10 downloads in the last day
37 downloads in the last week
166 downloads in the last month

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.

Build Status

Installation

npm install vouch

Basic Use

var vouch    = require('vouch');

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

Custom Error Messages

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.

Testing

npm test
npm loves you