Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including better-avj-errors with all npm packages installed. Try it out:

require("ajv/package.json"); // ajv is a peer dependency. var betterAvjErrors = require("better-avj-errors")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

better-avj-errors v0.3.0

JSON Schema validation for Human

better-avj-errors

JSON Schema validation for Human

Main goal of this library is to provide relevant error message like the following:

Enum Validation Error

Installation

$ yarn add better-avj-errors
$ # Or
$ npm i better-avj-errors

Usage

import Ajv from 'ajv';
// const Ajv = require('ajv');
import betterAjvErrors from 'better-avj-errors';
// const betterAjvErrors = require('better-avj-errors');

// You need to pass `jsonPointers: true`
const ajv = new Ajv({ jsonPointers: true });

// Load schema and data
const schema = ...;
const data = ...;

const validate = ajv.compile(schema);
const valid = validate(data);

if (!valid) {
  betterAjvErrors(schema, data, validate.errors);
}

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free