diff --git a/package.json b/package.json index d9077ae..7e373b6 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "np": "^7.6.1", "size-limit": "^7.0.8", "tsdx": "^0.14.1", + "json-schema": "^0.4.0", "tslib": "^2.4.0", "typescript": "^4.7.2" }, @@ -69,8 +70,7 @@ "ajv": ">=8" }, "dependencies": { - "json-schema": "^0.4.0", - "jsonpointer": "^5.0.0", + "jsonpointer": "^5.0.1", "leven": "^3.1.0" }, "resolutions": { diff --git a/src/index.ts b/src/index.ts index 1601847..f796fbf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,23 +1,22 @@ import { DefinedError, ErrorObject } from 'ajv'; -import type { JSONSchema6 } from 'json-schema'; import { ValidationError } from './types/ValidationError'; import { filterSingleErrorPerProperty } from './lib/filter'; import { getSuggestion } from './lib/suggestions'; import { cleanAjvMessage, getLastSegment, pointerToDotNotation, safeJsonPointer } from './lib/utils'; -export interface BetterAjvErrorsOptions { +export interface BetterAjvErrorsOptions { errors: ErrorObject[] | null | undefined; data: any; - schema: JSONSchema6; + schema: S; basePath?: string; } -export const betterAjvErrors = ({ +export const betterAjvErrors = ({ errors, data, schema, basePath = '{base}', -}: BetterAjvErrorsOptions): ValidationError[] => { +}: BetterAjvErrorsOptions): ValidationError[] => { if (!Array.isArray(errors) || errors.length === 0) { return []; } diff --git a/yarn.lock b/yarn.lock index 9a937bb..f72eee8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5078,10 +5078,10 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jsonpointer@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-5.0.0.tgz#f802669a524ec4805fa7389eadbc9921d5dc8072" - integrity sha512-PNYZIdMjVIvVgDSYKTT63Y+KZ6IZvGRNNWcxwD+GNnUz1MKPfv30J8ueCjdwcN0nDx2SlshgyB7Oy0epAzVRRg== +jsonpointer@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-5.0.1.tgz#2110e0af0900fd37467b5907ecd13a7884a1b559" + integrity sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ== jsprim@^1.2.2: version "1.4.2"