schema-shield 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -0
- package/dist/index.js +5 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/utils/main-utils.d.ts +1 -0
- package/dist/utils/main-utils.d.ts.map +1 -1
- package/lib/utils/main-utils.ts +12 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -8,11 +8,15 @@ var ValidationError = class extends Error {
|
|
|
8
8
|
instancePath = "";
|
|
9
9
|
data;
|
|
10
10
|
schema;
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.message = message;
|
|
14
|
+
}
|
|
11
15
|
_getCause(pointer = "#", instancePointer = "#") {
|
|
12
16
|
let schemaPath = `${pointer}/${this.keyword}`;
|
|
13
17
|
let instancePath = `${instancePointer}`;
|
|
14
18
|
if (typeof this.item !== "undefined") {
|
|
15
|
-
if (typeof this.item === "string" && this.item in this.schema) {
|
|
19
|
+
if (typeof this.item === "string" && this.schema && typeof this.schema === "object" && this.item in this.schema) {
|
|
16
20
|
schemaPath += `/${this.item}`;
|
|
17
21
|
}
|
|
18
22
|
instancePath += `/${this.item}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-utils.d.ts","sourceRoot":"","sources":["../../lib/utils/main-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,SAAS,CAAC;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G,CAAC;IACX,KAAK,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,CACE,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,kBAAkB,GAC3B,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;CAClC;AAID,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,OAAO,uBAuBlB;AAED,wBAAgB,cAAc,CAAC,GAAG,KAAA,UAUjC;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,IAAI,cAAc,CAO5E;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAE1D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAwCxD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAQ,GAAG,OAAO,CAE7E"}
|
package/lib/utils/main-utils.ts
CHANGED
|
@@ -20,11 +20,21 @@ export class ValidationError extends Error {
|
|
|
20
20
|
data?: any;
|
|
21
21
|
schema?: CompiledSchema;
|
|
22
22
|
|
|
23
|
+
constructor(message: string) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.message = message;
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
private _getCause(pointer = "#", instancePointer = "#"): ValidationError {
|
|
24
29
|
let schemaPath = `${pointer}/${this.keyword}`;
|
|
25
30
|
let instancePath = `${instancePointer}`;
|
|
26
31
|
if (typeof this.item !== "undefined") {
|
|
27
|
-
if (
|
|
32
|
+
if (
|
|
33
|
+
typeof this.item === "string" &&
|
|
34
|
+
this.schema &&
|
|
35
|
+
typeof this.schema === "object" &&
|
|
36
|
+
this.item in this.schema
|
|
37
|
+
) {
|
|
28
38
|
schemaPath += `/${this.item}`;
|
|
29
39
|
}
|
|
30
40
|
instancePath += `/${this.item}`;
|
|
@@ -88,6 +98,7 @@ export interface DefineErrorFunction {
|
|
|
88
98
|
options?: DefineErrorOptions
|
|
89
99
|
): ValidationError | void | true;
|
|
90
100
|
}
|
|
101
|
+
|
|
91
102
|
const FAIL_FAST_DEFINE_ERROR: DefineErrorFunction = () => true;
|
|
92
103
|
|
|
93
104
|
export function getDefinedErrorFunctionForKey(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "schema-shield",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A fast library that protects your JSON schema from invalid data.",
|
|
5
5
|
"repository": "git@github.com:Masquerade-Circus/schema-shield.git",
|
|
6
6
|
"author": "Masquerade <christian@masquerade-circus.net>",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@exodus/schemasafe": "^1.0.0",
|
|
89
89
|
"@release-it/conventional-changelog": "^5.1.1",
|
|
90
|
+
"@types/mocha": "^10.0.10",
|
|
90
91
|
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
91
92
|
"@typescript-eslint/parser": "^5.56.0",
|
|
92
93
|
"ajv": "^8.12.0",
|