JSON schema validation ... for humans.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
.jshintrc
.travis.yml
LICENSE.md
README.md
makefile
package.json

README.md

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