Skip to content

Commit 589aa59

Browse files
authored
feat: added the link property in validation error
1 parent b281bb1 commit 589aa59

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

declarations/validate.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type Extend = {
77
formatMaximum?: number | undefined;
88
formatExclusiveMinimum?: boolean | undefined;
99
formatExclusiveMaximum?: boolean | undefined;
10+
link?: string | undefined;
1011
};
1112
export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend;
1213
export type SchemaUtilErrorObject = ErrorObject & {

src/ValidationError.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,10 @@ class ValidationError extends Error {
852852
schemaText += `\n-> ${schemaPart.description}`;
853853
}
854854

855+
if (schemaPart.link) {
856+
schemaText += `\n-> Read more at ${schemaPart.link}`;
857+
}
858+
855859
return schemaText;
856860
}
857861

src/validate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const ajvKeywords = require("ajv-keywords");
1717
* @property {number=} formatMaximum
1818
* @property {boolean=} formatExclusiveMinimum
1919
* @property {boolean=} formatExclusiveMaximum
20+
* @property {string=} link
2021
*/
2122

2223
/** @typedef {(JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend} Schema */

test/__snapshots__/index.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ exports[`Validation should fail validation for enum 1`] = `
626626
- configuration.devtool should be one of these:
627627
string | false
628628
-> A developer tool to enhance debugging.
629+
-> Read more at https://webpack.js.org/configuration/devtool/
629630
Details:
630631
* configuration.devtool should be a string.
631632
* configuration.devtool should be false."
@@ -1537,6 +1538,7 @@ exports[`Validation should fail validation for oneOf #1 1`] = `
15371538
- configuration.entry should be one of these:
15381539
function | object { <key>: 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)
15391540
-> The entry point(s) of the compilation.
1541+
-> Read more at https://webpack.js.org/configuration/entry-context/#entry
15401542
Details:
15411543
* configuration.entry['foo'] should be one of these:
15421544
non-empty string | [non-empty string, ...] (should not have fewer than 1 item, should not have duplicate items)

test/fixtures/schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,7 @@
20812081
},
20822082
"devtool": {
20832083
"description": "A developer tool to enhance debugging.",
2084+
"link": "https://webpack.js.org/configuration/devtool/",
20842085
"anyOf": [
20852086
{
20862087
"type": "string"
@@ -2092,6 +2093,7 @@
20922093
},
20932094
"entry": {
20942095
"description": "The entry point(s) of the compilation.",
2096+
"link": "https://webpack.js.org/configuration/entry-context/#entry",
20952097
"anyOf": [
20962098
{
20972099
"$ref": "#/definitions/Entry"

0 commit comments

Comments
 (0)