schema-utils
Advanced tools
Comparing version 3.1.1 to 4.0.0
export default addAbsolutePathKeyword; | ||
export type Ajv = import("ajv").Ajv; | ||
export type ValidateFunction = import("ajv").ValidateFunction; | ||
export type Ajv = import("ajv").default; | ||
export type SchemaValidateFunction = import("ajv").SchemaValidateFunction; | ||
export type AnySchemaObject = import("ajv").AnySchemaObject; | ||
export type SchemaUtilErrorObject = import("../validate").SchemaUtilErrorObject; | ||
@@ -5,0 +6,0 @@ /** |
@@ -6,6 +6,6 @@ export type JSONSchema4 = import("json-schema").JSONSchema4; | ||
export type Extend = { | ||
formatMinimum?: number | undefined; | ||
formatMaximum?: number | undefined; | ||
formatExclusiveMinimum?: boolean | undefined; | ||
formatExclusiveMaximum?: boolean | undefined; | ||
formatMinimum?: string | undefined; | ||
formatMaximum?: string | undefined; | ||
formatExclusiveMinimum?: string | undefined; | ||
formatExclusiveMaximum?: string | undefined; | ||
link?: string | undefined; | ||
@@ -12,0 +12,0 @@ }; |
@@ -8,6 +8,8 @@ "use strict"; | ||
/** @typedef {import("ajv").Ajv} Ajv */ | ||
/** @typedef {import("ajv").default} Ajv */ | ||
/** @typedef {import("ajv").ValidateFunction} ValidateFunction */ | ||
/** @typedef {import("ajv").SchemaValidateFunction} SchemaValidateFunction */ | ||
/** @typedef {import("ajv").AnySchemaObject} AnySchemaObject */ | ||
/** @typedef {import("../validate").SchemaUtilErrorObject} SchemaUtilErrorObject */ | ||
@@ -57,8 +59,14 @@ | ||
function addAbsolutePathKeyword(ajv) { | ||
ajv.addKeyword("absolutePath", { | ||
ajv.addKeyword({ | ||
keyword: "absolutePath", | ||
type: "string", | ||
errors: true, | ||
type: "string", | ||
/** | ||
* @param {boolean} schema | ||
* @param {AnySchemaObject} parentSchema | ||
* @returns {SchemaValidateFunction} | ||
*/ | ||
compile(schema, parentSchema) { | ||
/** @type {ValidateFunction} */ | ||
/** @type {SchemaValidateFunction} */ | ||
const callback = data => { | ||
@@ -65,0 +73,0 @@ let passes = true; |
@@ -22,3 +22,2 @@ "use strict"; | ||
const tmpFormat = currentSchema.formatMinimum; | ||
const tmpExclusive = currentSchema.formatExclusiveMaximum; | ||
currentSchema.minLength = currentSchema.maxLength; | ||
@@ -28,4 +27,2 @@ currentSchema.maxLength = tmpLength; | ||
currentSchema.formatMaximum = tmpFormat; | ||
currentSchema.formatExclusiveMaximum = !currentSchema.formatExclusiveMinimum; | ||
currentSchema.formatExclusiveMinimum = !tmpExclusive; | ||
} | ||
@@ -32,0 +29,0 @@ |
@@ -6,3 +6,2 @@ "use strict"; | ||
}); | ||
exports.validate = validate; | ||
Object.defineProperty(exports, "ValidationError", { | ||
@@ -14,2 +13,3 @@ enumerable: true, | ||
}); | ||
exports.validate = validate; | ||
@@ -23,5 +23,7 @@ var _absolutePath = _interopRequireDefault(require("./keywords/absolutePath")); | ||
// Use CommonJS require for ajv libs so TypeScript consumers aren't locked into esModuleInterop (see #110). | ||
const Ajv = require("ajv"); | ||
const Ajv = require("ajv").default; | ||
const ajvKeywords = require("ajv-keywords"); | ||
const ajvKeywords = require("ajv-keywords").default; | ||
const addFormats = require("ajv-formats").default; | ||
/** @typedef {import("json-schema").JSONSchema4} JSONSchema4 */ | ||
@@ -37,6 +39,6 @@ | ||
* @typedef {Object} Extend | ||
* @property {number=} formatMinimum | ||
* @property {number=} formatMaximum | ||
* @property {boolean=} formatExclusiveMinimum | ||
* @property {boolean=} formatExclusiveMaximum | ||
* @property {string=} formatMinimum | ||
* @property {string=} formatMaximum | ||
* @property {string=} formatExclusiveMinimum | ||
* @property {string=} formatExclusiveMaximum | ||
* @property {string=} link | ||
@@ -63,4 +65,9 @@ */ | ||
/** | ||
* @type {Ajv} | ||
*/ | ||
const ajv = new Ajv({ | ||
strict: false, | ||
allErrors: true, | ||
@@ -70,3 +77,6 @@ verbose: true, | ||
}); | ||
ajvKeywords(ajv, ["instanceof", "formatMinimum", "formatMaximum", "patternRequired"]); // Custom keywords | ||
ajvKeywords(ajv, ["instanceof", "patternRequired"]); | ||
addFormats(ajv, { | ||
keywords: true | ||
}); // Custom keywords | ||
@@ -93,3 +103,3 @@ (0, _absolutePath.default)(ajv); | ||
// eslint-disable-next-line no-param-reassign | ||
error.dataPath = `[${idx}]${error.dataPath}`; | ||
error.instancePath = `[${idx}]${error.instancePath}`; | ||
@@ -142,3 +152,3 @@ if (error.children) { | ||
const { | ||
dataPath | ||
instancePath | ||
} = error; | ||
@@ -149,3 +159,3 @@ /** @type {Array<SchemaUtilErrorObject>} */ | ||
newErrors = newErrors.filter(oldError => { | ||
if (oldError.dataPath.includes(dataPath)) { | ||
if (oldError.instancePath.includes(instancePath)) { | ||
if (oldError.children) { | ||
@@ -152,0 +162,0 @@ children = children.concat(oldError.children.slice(0)); |
@@ -62,2 +62,10 @@ "use strict"; | ||
/** | ||
* @param {string} value | ||
* @returns {value is number} | ||
*/ | ||
function isNumeric(value) { | ||
return /^-?\d+$/.test(value); | ||
} | ||
/** | ||
* | ||
@@ -69,2 +77,3 @@ * @param {Array<SchemaUtilErrorObject>} array | ||
function filterMax(array, fn) { | ||
@@ -89,3 +98,3 @@ const evaluatedMax = array.reduce((max, item) => Math.max(max, fn(item)), 0); | ||
*/ | ||
error => error.dataPath ? error.dataPath.length : 0); | ||
error => error.instancePath ? error.instancePath.length : 0); | ||
newChildren = filterMax(newChildren, | ||
@@ -640,2 +649,5 @@ /** | ||
const properties = schema.properties ? Object.keys(schema.properties) : []; | ||
/** @type {Array<string>} */ | ||
// @ts-ignore | ||
const required = schema.required ? schema.required : []; | ||
@@ -786,6 +798,26 @@ const allProperties = [...new Set( | ||
keyword, | ||
dataPath: errorDataPath | ||
instancePath: errorInstancePath | ||
} = error; | ||
const dataPath = `${this.baseDataPath}${errorDataPath}`; | ||
const splittedInstancePath = errorInstancePath.split("/"); | ||
/** | ||
* @type {Array<string>} | ||
*/ | ||
const defaultValue = []; | ||
const prettyInstancePath = splittedInstancePath.reduce((acc, val) => { | ||
if (val.length > 0) { | ||
if (isNumeric(val)) { | ||
acc.push(`[${val}]`); | ||
} else if (/^\[/.test(val)) { | ||
acc.push(val); | ||
} else { | ||
acc.push(`.${val}`); | ||
} | ||
} | ||
return acc; | ||
}, defaultValue).join(""); | ||
const instancePath = `${this.baseDataPath}${prettyInstancePath}`; // const { keyword, instancePath: errorInstancePath } = error; | ||
// const instancePath = `${this.baseDataPath}${errorInstancePath.replace(/\//g, '.')}`; | ||
switch (keyword) { | ||
@@ -799,28 +831,26 @@ case "type": | ||
switch ( | ||
/** @type {import("ajv").TypeParams} */ | ||
params.type) { | ||
switch (params.type) { | ||
case "number": | ||
return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
case "integer": | ||
return `${dataPath} should be an ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be an ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
case "string": | ||
return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
case "boolean": | ||
return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
case "array": | ||
return `${dataPath} should be an array:\n${this.getSchemaPartText(parentSchema)}`; | ||
return `${instancePath} should be an array:\n${this.getSchemaPartText(parentSchema)}`; | ||
case "object": | ||
return `${dataPath} should be an object:\n${this.getSchemaPartText(parentSchema)}`; | ||
return `${instancePath} should be an object:\n${this.getSchemaPartText(parentSchema)}`; | ||
case "null": | ||
return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
default: | ||
return `${dataPath} should be:\n${this.getSchemaPartText(parentSchema)}`; | ||
return `${instancePath} should be:\n${this.getSchemaPartText(parentSchema)}`; | ||
} | ||
@@ -834,3 +864,3 @@ } | ||
} = error; | ||
return `${dataPath} should be an instance of ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be an instance of ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
} | ||
@@ -846,6 +876,4 @@ | ||
pattern | ||
} = | ||
/** @type {import("ajv").PatternParams} */ | ||
params; | ||
return `${dataPath} should match pattern ${JSON.stringify(pattern)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should match pattern ${JSON.stringify(pattern)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -861,10 +889,10 @@ | ||
format | ||
} = | ||
/** @type {import("ajv").FormatParams} */ | ||
params; | ||
return `${dataPath} should match format ${JSON.stringify(format)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should match format ${JSON.stringify(format)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
case "formatMinimum": | ||
case "formatExclusiveMinimum": | ||
case "formatMaximum": | ||
case "formatExclusiveMaximum": | ||
{ | ||
@@ -878,6 +906,4 @@ const { | ||
limit | ||
} = | ||
/** @type {import("ajv").ComparisonParams} */ | ||
params; | ||
return `${dataPath} should be ${comparison} ${JSON.stringify(limit)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should be ${comparison} ${JSON.stringify(limit)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -897,5 +923,3 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").ComparisonParams} */ | ||
params; | ||
} = params; | ||
const [, ...hints] = getHints( | ||
@@ -909,3 +933,3 @@ /** @type {Schema} */ | ||
return `${dataPath} ${hints.join(" ")}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} ${hints.join(" ")}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -921,6 +945,4 @@ | ||
multipleOf | ||
} = | ||
/** @type {import("ajv").MultipleOfParams} */ | ||
params; | ||
return `${dataPath} should be multiple of ${multipleOf}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should be multiple of ${multipleOf}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -936,6 +958,4 @@ | ||
missingPattern | ||
} = | ||
/** @type {import("ajv").PatternRequiredParams} */ | ||
params; | ||
return `${dataPath} should have property matching pattern ${JSON.stringify(missingPattern)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should have property matching pattern ${JSON.stringify(missingPattern)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -951,12 +971,10 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
} = params; | ||
if (limit === 1) { | ||
return `${dataPath} should be a non-empty string${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should be a non-empty string${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
const length = limit - 1; | ||
return `${dataPath} should be longer than ${length} character${length > 1 ? "s" : ""}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should be longer than ${length} character${length > 1 ? "s" : ""}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -972,11 +990,9 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
} = params; | ||
if (limit === 1) { | ||
return `${dataPath} should be a non-empty array${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should be a non-empty array${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
return `${dataPath} should not have fewer than ${limit} items${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should not have fewer than ${limit} items${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -992,11 +1008,9 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
} = params; | ||
if (limit === 1) { | ||
return `${dataPath} should be a non-empty object${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should be a non-empty object${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
return `${dataPath} should not have fewer than ${limit} properties${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should not have fewer than ${limit} properties${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1012,7 +1026,5 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
} = params; | ||
const max = limit + 1; | ||
return `${dataPath} should be shorter than ${max} character${max > 1 ? "s" : ""}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should be shorter than ${max} character${max > 1 ? "s" : ""}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1028,6 +1040,4 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
return `${dataPath} should not have more than ${limit} items${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should not have more than ${limit} items${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1043,6 +1053,4 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
return `${dataPath} should not have more than ${limit} properties${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should not have more than ${limit} properties${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1058,6 +1066,6 @@ | ||
i | ||
} = | ||
/** @type {import("ajv").UniqueItemsParams} */ | ||
params; | ||
return `${dataPath} should not contain the item '${error.data[i]}' twice${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should not contain the item '${ | ||
/** @type {{ data: Array<any> }} **/ | ||
error.data[i]}' twice${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1073,6 +1081,4 @@ | ||
limit | ||
} = | ||
/** @type {import("ajv").LimitParams} */ | ||
params; | ||
return `${dataPath} should not have more than ${limit} items${getSchemaNonTypes(parentSchema)}. These items are valid:\n${this.getSchemaPartText(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} should not have more than ${limit} items${getSchemaNonTypes(parentSchema)}. These items are valid:\n${this.getSchemaPartText(parentSchema)}`; | ||
} | ||
@@ -1085,3 +1091,3 @@ | ||
} = error; | ||
return `${dataPath} should contains at least one ${this.getSchemaPartText(parentSchema, ["contains"])} item${getSchemaNonTypes(parentSchema)}.`; | ||
return `${instancePath} should contains at least one ${this.getSchemaPartText(parentSchema, ["contains"])} item${getSchemaNonTypes(parentSchema)}.`; | ||
} | ||
@@ -1095,5 +1101,3 @@ | ||
} = error; | ||
const missingProperty = | ||
/** @type {import("ajv").DependenciesParams} */ | ||
params.missingProperty.replace(/^\./, ""); | ||
const missingProperty = params.missingProperty.replace(/^\./, ""); | ||
const hasProperty = parentSchema && Boolean( | ||
@@ -1104,3 +1108,3 @@ /** @type {Schema} */ | ||
parentSchema.properties[missingProperty]); | ||
return `${dataPath} misses the property '${missingProperty}'${getSchemaNonTypes(parentSchema)}.${hasProperty ? ` Should be:\n${this.getSchemaPartText(parentSchema, ["properties", missingProperty])}` : this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} misses the property '${missingProperty}'${getSchemaNonTypes(parentSchema)}.${hasProperty ? ` Should be:\n${this.getSchemaPartText(parentSchema, ["properties", missingProperty])}` : this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1116,6 +1120,4 @@ | ||
additionalProperty | ||
} = | ||
/** @type {import("ajv").AdditionalPropertiesParams} */ | ||
params; | ||
return `${dataPath} has an unknown property '${additionalProperty}'${getSchemaNonTypes(parentSchema)}. These properties are valid:\n${this.getSchemaPartText(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} has an unknown property '${additionalProperty}'${getSchemaNonTypes(parentSchema)}. These properties are valid:\n${this.getSchemaPartText(parentSchema)}`; | ||
} | ||
@@ -1132,5 +1134,3 @@ | ||
deps | ||
} = | ||
/** @type {import("ajv").DependenciesParams} */ | ||
params; | ||
} = params; | ||
const dependencies = deps.split(",").map( | ||
@@ -1142,3 +1142,3 @@ /** | ||
dep => `'${dep.trim()}'`).join(", "); | ||
return `${dataPath} should have properties ${dependencies} when property '${property}' is present${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath} should have properties ${dependencies} when property '${property}' is present${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1155,6 +1155,4 @@ | ||
propertyName | ||
} = | ||
/** @type {import("ajv").PropertyNamesParams} */ | ||
params; | ||
return `${dataPath} property name '${propertyName}' is invalid${getSchemaNonTypes(parentSchema)}. Property names should be match format ${JSON.stringify(schema.format)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} = params; | ||
return `${instancePath} property name '${propertyName}' is invalid${getSchemaNonTypes(parentSchema)}. Property names should be match format ${JSON.stringify(schema.format)}.${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1173,6 +1171,6 @@ | ||
parentSchema.enum.length === 1) { | ||
return `${dataPath} should be ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
} | ||
return `${dataPath} should be one of these:\n${this.getSchemaPartText(parentSchema)}`; | ||
return `${instancePath} should be one of these:\n${this.getSchemaPartText(parentSchema)}`; | ||
} | ||
@@ -1185,3 +1183,3 @@ | ||
} = error; | ||
return `${dataPath} should be equal to constant ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
return `${instancePath} should be equal to constant ${this.getSchemaPartText(parentSchema, false, true)}`; | ||
} | ||
@@ -1197,3 +1195,3 @@ | ||
if (canApplyNot(error.schema)) { | ||
return `${dataPath} should be any ${schemaOutput}${postfix}.`; | ||
return `${instancePath} should be any ${schemaOutput}${postfix}.`; | ||
} | ||
@@ -1205,3 +1203,3 @@ | ||
} = error; | ||
return `${dataPath} should not be ${this.getSchemaPartText(schema, false, true)}${parentSchema && likeObject(parentSchema) ? `\n${this.getSchemaPartText(parentSchema)}` : ""}`; | ||
return `${instancePath} should not be ${this.getSchemaPartText(schema, false, true)}${parentSchema && likeObject(parentSchema) ? `\n${this.getSchemaPartText(parentSchema)}` : ""}`; | ||
} | ||
@@ -1234,3 +1232,3 @@ | ||
filteredChildren = groupChildrenByFirstChild(filteredChildren); | ||
return `${dataPath} should be one of these:\n${this.getSchemaPartText(parentSchema)}\nDetails:\n${filteredChildren.map( | ||
return `${instancePath} should be one of these:\n${this.getSchemaPartText(parentSchema)}\nDetails:\n${filteredChildren.map( | ||
/** | ||
@@ -1243,3 +1241,3 @@ * @param {SchemaUtilErrorObject} nestedError | ||
return `${dataPath} should be one of these:\n${this.getSchemaPartText(parentSchema)}`; | ||
return `${instancePath} should be one of these:\n${this.getSchemaPartText(parentSchema)}`; | ||
} | ||
@@ -1255,6 +1253,4 @@ | ||
failingKeyword | ||
} = | ||
/** @type {import("ajv").IfParams} */ | ||
params; | ||
return `${dataPath} should match "${failingKeyword}" schema:\n${this.getSchemaPartText(parentSchema, [failingKeyword])}`; | ||
} = params; | ||
return `${instancePath} should match "${failingKeyword}" schema:\n${this.getSchemaPartText(parentSchema, [failingKeyword])}`; | ||
} | ||
@@ -1268,3 +1264,3 @@ | ||
} = error; | ||
return `${dataPath}: ${message}${this.getSchemaPartDescription(parentSchema)}`; | ||
return `${instancePath}: ${message}${this.getSchemaPartDescription(parentSchema)}`; | ||
} | ||
@@ -1283,3 +1279,3 @@ | ||
return `${dataPath} ${message} (${ErrorInJSON}).\n${this.getSchemaPartText(parentSchema, false)}`; | ||
return `${instancePath} ${message} (${ErrorInJSON}).\n${this.getSchemaPartText(parentSchema, false)}`; | ||
} | ||
@@ -1286,0 +1282,0 @@ } |
{ | ||
"name": "schema-utils", | ||
"version": "3.1.1", | ||
"version": "4.0.0", | ||
"description": "webpack Validation Utils", | ||
@@ -17,3 +17,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">= 10.13.0" | ||
"node": ">= 12.13.0" | ||
}, | ||
@@ -49,28 +49,29 @@ "scripts": { | ||
"dependencies": { | ||
"@types/json-schema": "^7.0.8", | ||
"ajv": "^6.12.5", | ||
"ajv-keywords": "^3.5.2" | ||
"@types/json-schema": "^7.0.9", | ||
"ajv": "^8.8.0", | ||
"ajv-keywords": "^5.0.0", | ||
"ajv-formats": "^2.1.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.14.3", | ||
"@babel/core": "^7.14.6", | ||
"@babel/preset-env": "^7.14.7", | ||
"@commitlint/cli": "^12.1.4", | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@babel/cli": "^7.16.0", | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.0", | ||
"@commitlint/cli": "^14.1.0", | ||
"@commitlint/config-conventional": "^14.1.0", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-jest": "^27.0.6", | ||
"babel-jest": "^27.3.1", | ||
"cross-env": "^7.0.3", | ||
"del": "^6.0.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.31.0", | ||
"del-cli": "^4.0.1", | ||
"eslint": "^8.0.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"husky": "^6.0.0", | ||
"jest": "^27.0.6", | ||
"lint-staged": "^11.0.1", | ||
"eslint-plugin-import": "^2.25.3", | ||
"husky": "^7.0.4", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^12.0.2", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.3.2", | ||
"standard-version": "^9.3.1", | ||
"prettier": "^2.4.1", | ||
"standard-version": "^9.3.2", | ||
"typescript": "^4.3.5", | ||
"webpack": "^5.45.1" | ||
"webpack": "^5.64.1" | ||
}, | ||
@@ -77,0 +78,0 @@ "keywords": [ |
66292
1692
4
+ Addedajv-formats@^2.1.1
+ Addedajv@8.12.0(transitive)
+ Addedajv-formats@2.1.1(transitive)
+ Addedajv-keywords@5.1.0(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
- Removedajv@6.12.6(transitive)
- Removedajv-keywords@3.5.2(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
Updated@types/json-schema@^7.0.9
Updatedajv@^8.8.0
Updatedajv-keywords@^5.0.0