Gathering detailed insights and metrics for @apideck/better-ajv-errors
Gathering detailed insights and metrics for @apideck/better-ajv-errors
Gathering detailed insights and metrics for @apideck/better-ajv-errors
Gathering detailed insights and metrics for @apideck/better-ajv-errors
Human-friendly JSON Schema validation for APIs 👮♀️
npm install @apideck/better-ajv-errors
97.5
Supply Chain
89.5
Quality
81.5
Maintenance
100
Vulnerability
99.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
41 Stars
61 Commits
6 Forks
6 Watching
9 Branches
6 Contributors
Updated on 18 Mar 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.1%
542,911
Compared to previous day
Last week
0.7%
3,042,057
Compared to previous week
Last month
3.1%
13,047,332
Compared to previous month
Last year
8.4%
155,151,524
Compared to previous year
3
1
Human-friendly JSON Schema validation for APIs
1$ yarn add @apideck/better-ajv-errors
or
1$ npm i @apideck/better-ajv-errors
Also make sure that you've installed ajv at version 8 or higher.
After validating some data with ajv, pass the errors to betterAjvErrors
1import Ajv from 'ajv'; 2import { betterAjvErrors } from '@apideck/better-ajv-errors'; 3 4// Without allErrors: true, ajv will only return the first error 5const ajv = new Ajv({ allErrors: true }); 6 7const valid = ajv.validate(schema, data); 8 9if (!valid) { 10 const betterErrors = betterAjvErrors({ schema, data, errors: ajv.errors }); 11}
Function that formats ajv validation errors in a human-friendly format.
options: BetterAjvErrorsOptions
errors: ErrorObject[] | null | undefined
Your ajv errors, you will find these in the errors
property of your ajv instance (ErrorObject
is a type from the ajv package).data: Object
The data you passed to ajv to be validated.schema: JSONSchema
The schema you passed to ajv to validate against.basePath?: string
An optional base path to prefix paths returned by betterAjvErrors
. For example, in APIs, it could be useful to use '{requestBody}'
or '{queryParemeters}'
as a basePath. This will make it clear to users where exactly the error occurred.ValidationError[]
Array of formatted errors (properties of ValidationError
below)
message: string
Formatted error messagesuggestion?: string
Optional suggestion based on provided data and schemapath: string
Object path where the error occurred (example: .foo.bar.0.quz
)context: { errorType: DefinedError['keyword']; [additionalContext: string]: unknown }
errorType
is error.keyword
proxied from ajv
. errorType
can be used as a key for i18n if needed. There might be additional properties on context, based on the type of error.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 2/17 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
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
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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