Gathering detailed insights and metrics for @readme/better-ajv-errors
Gathering detailed insights and metrics for @readme/better-ajv-errors
Gathering detailed insights and metrics for @readme/better-ajv-errors
Gathering detailed insights and metrics for @readme/better-ajv-errors
JSON Schema validation for Humans 👨🎤
npm install @readme/better-ajv-errors
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.2
Supply Chain
99.6
Quality
88.1
Maintenance
100
Vulnerability
100
License
JavaScript (99.02%)
TypeScript (0.98%)
Total Downloads
23,807,297
Last Day
16,660
Last Week
318,342
Last Month
1,365,037
Last Year
13,005,715
NOASSERTION License
2 Stars
390 Commits
1 Forks
1 Watchers
1 Branches
9 Contributors
Updated on Jul 01, 2025
Minified
Minified + Gzipped
Latest Version
2.3.2
Package Id
@readme/better-ajv-errors@2.3.2
Unpacked Size
91.39 kB
Size
15.23 kB
File Count
28
NPM Version
10.9.2
Node Version
20.16.0
Published on
Feb 28, 2025
Cumulative downloads
Total Downloads
Last Day
-24.2%
16,660
Compared to previous day
Last Week
-7.7%
318,342
Compared to previous week
Last Month
7.2%
1,365,037
Compared to previous month
Last Year
77.6%
13,005,715
Compared to previous year
1
JSON Schema validation for Human 👨🎤
Main goal of this library is to provide relevant error messages like the following:
better-ajv-errors
^^^^^^
pointers.colorize
option for disabling colorization in format: cli
output.1$ npm i @readme/better-ajv-errors 2$ yarn add @readme/better-ajv-errors 3$ pnpm add @readme/better-ajv-errors
Also make sure that you installed ajv package to validate data against JSON schemas.
First, you need to validate your payload with ajv
. If it's invalid then you can pass validate.errors
object into better-ajv-errors
.
1import Ajv from 'ajv'; 2import betterAjvErrors from '@readme/better-ajv-errors'; 3// const Ajv = require('ajv'); 4// const betterAjvErrors = require('@readme/better-ajv-errors'); 5 6// You need to pass `{ jsonPointers: true }` for older versions of ajv 7const ajv = new Ajv(); 8 9// Load schema and data 10const schema = ...; 11const data = ...; 12 13const validate = ajv.compile(schema); 14const valid = validate(data); 15 16if (!valid) { 17 const output = betterAjvErrors(schema, data, validate.errors); 18 console.log(output); 19}
Returns formatted validation error to print in console
. See options.format
for further details.
Type: Object
The JSON Schema you used for validation with ajv
Type: Object
The JSON payload you validate against using ajv
Type: Array
Array of ajv validation errors
Type: Object
Type: boolean
Default: true
When disabled, if you are outputting cli
formatting it will be without colorized or styled content.
Type: string
Default: cli
Values: cli
js
Use default cli
output format if you want to print beautiful validation errors like following:
Or, use js
if you are planning to use this with some API. Your output will look like following:
1[ 2 { 3 start: { line: 6, column: 15, offset: 70 }, 4 end: { line: 6, column: 26, offset: 81 }, 5 error: '/content/0/type should be equal to one of the allowed values: panel, paragraph, ...', 6 suggestion: 'Did you mean paragraph?', 7 }, 8];
Type: number
null
Default: null
If you have an unindented JSON payload and you want the error output indented.
This option have no effect when using the json
option.
Type: string
null
Default: null
Raw JSON payload used when formatting codeframe. Gives accurate line and column listings.
No vulnerabilities found.
No security vulnerabilities found.