🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@stoplight/better-ajv-errors

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/better-ajv-errors

JSON Schema validation for Human

1.0.3
latest
Source
npm
Version published
Weekly downloads
1.1M
-8.14%
Maintainers
1
Weekly downloads
 
Created

What is @stoplight/better-ajv-errors?

@stoplight/better-ajv-errors is a utility package designed to provide more human-readable error messages when using the AJV JSON schema validator. It enhances the default error messages provided by AJV, making it easier to understand and debug schema validation issues.

What are @stoplight/better-ajv-errors's main functionalities?

Human-Readable Error Messages

This feature allows you to generate more readable error messages from AJV validation errors. The code sample demonstrates how to use @stoplight/better-ajv-errors to transform AJV's default error messages into a more understandable format.

const Ajv = require('ajv');
const betterAjvErrors = require('@stoplight/better-ajv-errors');

const ajv = new Ajv();
const schema = {
  type: 'object',
  properties: {
    name: { type: 'string' },
    age: { type: 'integer' }
  },
  required: ['name', 'age']
};

const data = {
  name: 'John Doe',
  age: 'twenty-five'
};

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

if (!valid) {
  const output = betterAjvErrors(schema, data, validate.errors, { format: 'js' });
  console.log(output);
}

Other packages similar to @stoplight/better-ajv-errors

Keywords

json-schema

FAQs

Package last updated on 22 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts