1.0.1 • Published 6 years ago

nen-ajv-errors v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

NEN-AJV-ERRORS

Build Status

make errors of ajv to be more human readable format.

INSTALL

yarn add ajv-errors

USAGE

var ajvErrors = require('ajv-errors');
var Ajv = require('ajv');
var ajv = new Ajv({ allErrors: true });
var isValid = ajv.validate(schema, data);

if (!isValid) {
  var errors = ajvErrors(ajv.errors);
  // errors will be an object like below
  /* { 
      field1: 'error message',
      field2: 'error message'
    }
  */
}