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
77.5
Maintenance
100
Vulnerability
100
License
JavaScript (98.97%)
TypeScript (0.71%)
Shell (0.32%)
Total Downloads
27,400,499
Last Day
64,506
Last Week
271,040
Last Month
1,250,813
Last Year
13,946,059
2 Stars
1,073 Commits
3 Watching
12 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
3.0.1
Package Id
@sidvind/better-ajv-errors@3.0.1
Unpacked Size
424.75 kB
Size
95.66 kB
File Count
10
NPM Version
8.19.4
Node Version
16.20.2
Publised On
09 Sept 2024
Cumulative downloads
Total Downloads
Last day
-0.5%
64,506
Compared to previous day
Last week
-14.5%
271,040
Compared to previous week
Last month
4.7%
1,250,813
Compared to previous month
Last year
66.2%
13,946,059
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.
Reason
no binaries found in the repo
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
SAST tool is run on all commits
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
dangerous workflow patterns detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More