Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
544K
decreased by-20.79%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc