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

@sidvind/better-ajv-errors

Package Overview
Dependencies
Maintainers
0
Versions
20
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

4.0.0
latest
Source
npm
Version published
Weekly downloads
472K
-17.3%
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

json-schema

FAQs

Package last updated on 08 Mar 2025

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