diff --git a/declarations/validate.d.ts b/declarations/validate.d.ts index 061ee79..a04b6dd 100644 --- a/declarations/validate.d.ts +++ b/declarations/validate.d.ts @@ -7,6 +7,7 @@ export type Extend = { formatMaximum?: number | undefined; formatExclusiveMinimum?: boolean | undefined; formatExclusiveMaximum?: boolean | undefined; + link?: string | undefined; }; export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend; export type SchemaUtilErrorObject = ErrorObject & { diff --git a/src/ValidationError.js b/src/ValidationError.js index 1734180..921b184 100644 --- a/src/ValidationError.js +++ b/src/ValidationError.js @@ -852,6 +852,10 @@ class ValidationError extends Error { schemaText += `\n-> ${schemaPart.description}`; } + if (schemaPart.link) { + schemaText += `\n-> Read more at ${schemaPart.link}`; + } + return schemaText; } diff --git a/src/validate.js b/src/validate.js index b9808e5..2522241 100644 --- a/src/validate.js +++ b/src/validate.js @@ -17,6 +17,7 @@ const ajvKeywords = require("ajv-keywords"); * @property {number=} formatMaximum * @property {boolean=} formatExclusiveMinimum * @property {boolean=} formatExclusiveMaximum + * @property {string=} link */ /** @typedef {(JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend} Schema */ diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index 9f628cb..4f7e71a 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -626,6 +626,7 @@ exports[`Validation should fail validation for enum 1`] = ` - configuration.devtool should be one of these: string | false -> A developer tool to enhance debugging. + -> Read more at https://webpack.js.org/configuration/devtool/ Details: * configuration.devtool should be a string. * configuration.devtool should be false." @@ -1537,6 +1538,7 @@ exports[`Validation should fail validation for oneOf #1 1`] = ` - configuration.entry should be one of these: function | object { : non-empty string | [non-empty string, ...] (should not have fewer than 1 item, should not have duplicate items) } (should not have fewer than 1 property) | non-empty string | [non-empty string, ...] (should not have fewer than 1 item, should not have duplicate items) -> The entry point(s) of the compilation. + -> Read more at https://webpack.js.org/configuration/entry-context/#entry Details: * configuration.entry['foo'] should be one of these: non-empty string | [non-empty string, ...] (should not have fewer than 1 item, should not have duplicate items) diff --git a/test/fixtures/schema.json b/test/fixtures/schema.json index 24dc93e..26008d1 100644 --- a/test/fixtures/schema.json +++ b/test/fixtures/schema.json @@ -2081,6 +2081,7 @@ }, "devtool": { "description": "A developer tool to enhance debugging.", + "link": "https://webpack.js.org/configuration/devtool/", "anyOf": [ { "type": "string" @@ -2092,6 +2093,7 @@ }, "entry": { "description": "The entry point(s) of the compilation.", + "link": "https://webpack.js.org/configuration/entry-context/#entry", "anyOf": [ { "$ref": "#/definitions/Entry"