Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sidvind/better-ajv-errors

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sidvind/better-ajv-errors

JSON Schema validation for Human

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
319K
decreased by-9.36%
Maintainers
0
Weekly downloads
 
Created

What is @sidvind/better-ajv-errors?

@sidvind/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 @sidvind/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 @sidvind/better-ajv-errors to enhance the error messages for a simple JSON schema validation.

const Ajv = require('ajv');
const betterAjvErrors = require('@sidvind/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 @sidvind/better-ajv-errors

Keywords

FAQs

Package last updated on 09 Sep 2024

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