Skip to content

Commit

Permalink
Loosen typing for JSON schema object
Browse files Browse the repository at this point in the history
  • Loading branch information
elsmr committed Mar 22, 2023
1 parent 1da109a commit 0262060
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -62,15 +62,15 @@
"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"
},
"peerDependencies": {
"ajv": ">=8"
},
"dependencies": {
"json-schema": "^0.4.0",
"jsonpointer": "^5.0.0",
"jsonpointer": "^5.0.1",
"leven": "^3.1.0"
},
"resolutions": {
Expand Down
9 changes: 4 additions & 5 deletions 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<S = any> {
errors: ErrorObject[] | null | undefined;
data: any;
schema: JSONSchema6;
schema: S;
basePath?: string;
}

export const betterAjvErrors = ({
export const betterAjvErrors = <S = any>({
errors,
data,
schema,
basePath = '{base}',
}: BetterAjvErrorsOptions): ValidationError[] => {
}: BetterAjvErrorsOptions<S>): ValidationError[] => {
if (!Array.isArray(errors) || errors.length === 0) {
return [];
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -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"
Expand Down

0 comments on commit 0262060

Please sign in to comment.