Gathering detailed insights and metrics for @sidvind/better-ajv-errors
Gathering detailed insights and metrics for @sidvind/better-ajv-errors
Gathering detailed insights and metrics for @sidvind/better-ajv-errors
Gathering detailed insights and metrics for @sidvind/better-ajv-errors
JSON Schema validation for Human 👨🎤
npm install @sidvind/better-ajv-errors
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.3
Supply Chain
100
Quality
78.1
Maintenance
100
Vulnerability
99.6
License
JavaScript (99.66%)
Shell (0.34%)
Built with Next.js • Fully responsive • SEO optimized • Open source ready
Total Downloads
37,807,827
Last Day
24,806
Last Week
493,972
Last Month
2,163,067
Last Year
19,019,111
NOASSERTION License
2 Stars
1,254 Commits
2 Watchers
10 Branches
1 Contributors
Updated on Sep 06, 2025
Latest Version
4.0.0
Package Id
@sidvind/better-ajv-errors@4.0.0
Unpacked Size
462.10 kB
Size
101.50 kB
File Count
10
NPM Version
8.19.4
Node Version
16.20.2
Published on
Mar 08, 2025
Cumulative downloads
Total Downloads
Last Day
-17.1%
24,806
Compared to previous day
Last Week
4.5%
493,972
Compared to previous week
Last Month
5.4%
2,163,067
Compared to previous month
Last Year
86.4%
19,019,111
Compared to previous year
JSON Schema validation for Human 👨🎤
Main goal of this library is to provide relevant error messages like the following:
This fork removes the legacy build and thus drops dependencies such as core-js
and @babel/runtime
which is not needed on modern installations.
The following PRs from upstream are merged:
The following PRs has been merged upstream:
1$ npm i @sidvind/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 '@sidvind/better-ajv-errors'; 3// const Ajv = require('ajv'); 4// const betterAjvErrors = require('@sidvind/better-ajv-errors').default; 5// Or 6// const { default: betterAjvErrors } = require('@sidvid/better-ajv-errors'); 7 8// You need to pass `{ jsonPointers: true }` for older versions of ajv 9const ajv = new Ajv(); 10 11// Load schema and data 12const schema = ...; 13const data = ...; 14 15const validate = ajv.compile(schema); 16const valid = validate(data); 17 18if (!valid) { 19 const output = betterAjvErrors(schema, data, validate.errors); 20 console.log(output); 21}
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: 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: 6 '/content/0/type should be equal to one of the allowed values: panel, paragraph, ...', 7 suggestion: 'Did you mean paragraph?', 8 }, 9];
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.