jjve

Render JJV errors

  • jjve

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
jjve
440.5.26 years ago9 years agoMinified + gzip package size for jjve in KB

Readme

JJV Errors (jjve) Build Status
This is a library to render JJVjjv validation output.

Usage

var jjv = require('jjv');
var jjve = require('jjve');

var env = jjv();
var je = jjve(env);

var schema = {
  type: 'object',
  properties: { ok: { type: 'boolean' } },
};

var data = { ok: 1 };

var result = env.validate(schema, data);

if (result) {
  var errors = je(schema, data, result);
  console.log(JSON.stringify(errors, null, 4));
}

Output
[
    {
        "code": "INVALID_TYPE",
        "message": "Invalid type: integer should be boolean",
        "data": 1,
        "path": "$.ok"
    }
]

License

This work is licensed under the MIT License (see the LICENSE file).
Error messages derived from z-schemaz-schema (see the NOTICE file).