json-schema-library 5.3.0 → 7.0.0

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.
Files changed (161) hide show
  1. package/.editorconfig +1 -0
  2. package/.prettierignore +1 -0
  3. package/.prettierrc +7 -0
  4. package/CHANGELOG.md +106 -0
  5. package/README.md +811 -199
  6. package/TASKS.md +3 -81
  7. package/dist/index.d.ts +29 -71
  8. package/dist/jsonSchemaLibrary.js +1 -1
  9. package/dist/lib/SchemaService.d.ts +6 -8
  10. package/dist/lib/{addSchema.d.ts → addRemoteSchema.d.ts} +2 -1
  11. package/dist/lib/addValidator.d.ts +3 -2
  12. package/dist/lib/compile/getRef.d.ts +2 -1
  13. package/dist/lib/compile/index.d.ts +15 -1
  14. package/dist/lib/compile/types.d.ts +5 -0
  15. package/dist/lib/config/strings.d.ts +1 -39
  16. package/dist/lib/draft/index.d.ts +132 -0
  17. package/dist/lib/draft04/index.d.ts +7 -0
  18. package/dist/lib/draft06/compile/index.d.ts +16 -0
  19. package/dist/lib/draft06/index.d.ts +7 -0
  20. package/dist/lib/draft06/validation/keyword.d.ts +3 -0
  21. package/dist/lib/draft06/validation/type.d.ts +10 -0
  22. package/dist/lib/draft06/validation/typeKeywordMapping.d.ts +13 -0
  23. package/dist/lib/draft07/index.d.ts +7 -0
  24. package/dist/lib/each.d.ts +3 -2
  25. package/dist/lib/eachSchema.d.ts +2 -4
  26. package/dist/lib/getChildSchemaSelection.d.ts +7 -5
  27. package/dist/lib/getSchema.d.ts +2 -2
  28. package/dist/lib/getTemplate.d.ts +1 -1
  29. package/dist/lib/getTypeOf.d.ts +2 -1
  30. package/dist/lib/isValid.d.ts +1 -1
  31. package/dist/lib/jsoneditor/index.d.ts +7 -0
  32. package/dist/lib/resolveAllOf.d.ts +1 -1
  33. package/dist/lib/resolveAnyOf.d.ts +1 -1
  34. package/dist/lib/resolveOneOf.fuzzy.d.ts +1 -1
  35. package/dist/lib/resolveOneOf.strict.d.ts +2 -2
  36. package/dist/lib/{resolveRef.withOverwrite.d.ts → resolveRef.merge.d.ts} +0 -0
  37. package/dist/lib/schema/getTypeDefs.d.ts +6 -4
  38. package/dist/lib/schema/getTypeId.d.ts +1 -1
  39. package/dist/lib/schema/types.d.ts +7 -57
  40. package/dist/lib/step.d.ts +5 -5
  41. package/dist/lib/types.d.ts +11 -3
  42. package/dist/lib/utils/createCustomError.d.ts +8 -11
  43. package/dist/lib/utils/filter.d.ts +4 -4
  44. package/dist/lib/utils/flattenArray.d.ts +1 -1
  45. package/dist/lib/utils/merge.d.ts +3 -0
  46. package/dist/lib/utils/punycode.ucs2decode.d.ts +1 -1
  47. package/dist/lib/validate.d.ts +2 -2
  48. package/dist/lib/validateAsync.d.ts +1 -1
  49. package/dist/lib/validation/errors.d.ts +1 -3
  50. package/dist/lib/validation/format.d.ts +4 -11
  51. package/dist/lib/validation/keyword.d.ts +2 -27
  52. package/dist/lib/validation/type.d.ts +3 -10
  53. package/dist/lib/validation/typeKeywordMapping.d.ts +4 -4
  54. package/dist/module/index.js +23 -32
  55. package/dist/module/lib/SchemaService.js +7 -4
  56. package/dist/module/lib/{addSchema.js → addRemoteSchema.js} +2 -4
  57. package/dist/module/lib/addValidator.js +3 -4
  58. package/dist/module/lib/compile/getRef.js +1 -1
  59. package/dist/module/lib/compile/index.js +43 -18
  60. package/dist/module/lib/compile/types.js +1 -0
  61. package/dist/module/lib/config/strings.js +15 -2
  62. package/dist/module/lib/createSchemaOf.js +1 -1
  63. package/dist/module/lib/draft/index.js +133 -0
  64. package/dist/module/lib/draft04/index.js +90 -0
  65. package/dist/module/lib/draft06/compile/index.js +77 -0
  66. package/dist/module/lib/draft06/index.js +96 -0
  67. package/dist/module/lib/draft06/validation/keyword.js +168 -0
  68. package/dist/module/lib/draft06/validation/type.js +31 -0
  69. package/dist/module/lib/draft06/validation/typeKeywordMapping.js +15 -0
  70. package/dist/module/lib/draft07/index.js +96 -0
  71. package/dist/module/lib/each.js +2 -2
  72. package/dist/module/lib/eachSchema.js +28 -19
  73. package/dist/module/lib/getChildSchemaSelection.js +7 -6
  74. package/dist/module/lib/getSchema.js +4 -2
  75. package/dist/module/lib/getTemplate.js +42 -15
  76. package/dist/module/lib/jsoneditor/index.js +16 -0
  77. package/dist/module/lib/resolveAllOf.js +3 -4
  78. package/dist/module/lib/resolveOneOf.fuzzy.js +13 -3
  79. package/dist/module/lib/resolveOneOf.strict.js +49 -2
  80. package/dist/module/lib/{resolveRef.withOverwrite.js → resolveRef.merge.js} +0 -0
  81. package/dist/module/lib/resolveRef.strict.js +8 -0
  82. package/dist/module/lib/schema/getTypeDefs.js +14 -3
  83. package/dist/module/lib/schema/getTypeId.js +10 -6
  84. package/dist/module/lib/schema/types.js +33 -9
  85. package/dist/module/lib/step.js +67 -13
  86. package/dist/module/lib/types.js +7 -1
  87. package/dist/module/lib/utils/createCustomError.js +4 -4
  88. package/dist/module/lib/utils/filter.js +3 -5
  89. package/dist/module/lib/utils/flattenArray.js +4 -3
  90. package/dist/module/lib/utils/merge.js +4 -0
  91. package/dist/module/lib/utils/punycode.ucs2decode.js +4 -3
  92. package/dist/module/lib/validate.js +34 -8
  93. package/dist/module/lib/validateAsync.js +7 -7
  94. package/dist/module/lib/validation/errors.js +16 -3
  95. package/dist/module/lib/validation/format.js +115 -8
  96. package/dist/module/lib/validation/keyword.js +79 -32
  97. package/dist/module/lib/validation/type.js +2 -1
  98. package/index.ts +46 -32
  99. package/lib/SchemaService.ts +18 -11
  100. package/lib/{addSchema.ts → addRemoteSchema.ts} +3 -5
  101. package/lib/addValidator.ts +15 -12
  102. package/lib/compile/getRef.ts +3 -4
  103. package/lib/compile/index.ts +65 -19
  104. package/lib/compile/types.ts +6 -0
  105. package/lib/config/strings.ts +17 -3
  106. package/lib/createSchemaOf.ts +1 -3
  107. package/lib/draft/index.ts +201 -0
  108. package/lib/draft04/index.ts +95 -0
  109. package/lib/draft06/compile/index.ts +104 -0
  110. package/lib/draft06/index.ts +101 -0
  111. package/lib/draft06/validation/keyword.ts +199 -0
  112. package/lib/draft06/validation/type.ts +47 -0
  113. package/lib/draft06/validation/typeKeywordMapping.ts +15 -0
  114. package/lib/draft07/index.ts +101 -0
  115. package/lib/each.ts +11 -4
  116. package/lib/eachSchema.ts +45 -32
  117. package/lib/getChildSchemaSelection.ts +14 -7
  118. package/lib/getSchema.ts +18 -9
  119. package/lib/getTemplate.ts +155 -42
  120. package/lib/getTypeOf.ts +2 -1
  121. package/lib/isValid.ts +7 -3
  122. package/lib/jsoneditor/index.ts +20 -0
  123. package/lib/resolveAllOf.ts +10 -6
  124. package/lib/resolveAnyOf.ts +7 -3
  125. package/lib/resolveOneOf.fuzzy.ts +26 -9
  126. package/lib/resolveOneOf.strict.ts +63 -5
  127. package/lib/{resolveRef.withOverwrite.ts → resolveRef.merge.ts} +0 -0
  128. package/lib/resolveRef.strict.ts +9 -0
  129. package/lib/schema/getTypeDefs.ts +19 -7
  130. package/lib/schema/getTypeId.ts +11 -8
  131. package/lib/schema/types.ts +41 -9
  132. package/lib/step.ts +109 -25
  133. package/lib/types.ts +23 -5
  134. package/lib/utils/createCustomError.ts +8 -13
  135. package/lib/utils/filter.ts +7 -9
  136. package/lib/utils/flattenArray.ts +5 -4
  137. package/lib/utils/merge.ts +5 -0
  138. package/lib/utils/punycode.ucs2decode.ts +6 -5
  139. package/lib/validate.ts +47 -16
  140. package/lib/validateAsync.ts +15 -14
  141. package/lib/validation/errors.ts +17 -6
  142. package/lib/validation/format.ts +147 -13
  143. package/lib/validation/keyword.ts +172 -103
  144. package/lib/validation/type.ts +5 -1
  145. package/package.json +75 -63
  146. package/{dist/module/remotes/draft04.json → remotes/draft06.json} +47 -42
  147. package/remotes/draft07.json +172 -0
  148. package/remotes/draft2019-09.json +86 -0
  149. package/tsconfig.json +3 -10
  150. package/dist/lib/cores/CoreInterface.d.ts +0 -23
  151. package/dist/lib/cores/Draft04.d.ts +0 -13
  152. package/dist/lib/cores/JsonEditor.d.ts +0 -13
  153. package/dist/module/lib/cores/CoreInterface.js +0 -51
  154. package/dist/module/lib/cores/Draft04.js +0 -52
  155. package/dist/module/lib/cores/JsonEditor.js +0 -51
  156. package/dist/module/remotes/index.js +0 -10
  157. package/dist/remotes/index.d.ts +0 -5
  158. package/lib/cores/CoreInterface.ts +0 -76
  159. package/lib/cores/Draft04.ts +0 -66
  160. package/lib/cores/JsonEditor.ts +0 -64
  161. package/remotes/index.ts +0 -11
@@ -1,51 +0,0 @@
1
- import compileSchema from "../compileSchema";
2
- import resolveAnyOf from "../resolveAnyOf";
3
- import resolveAllOf from "../resolveAllOf";
4
- /* eslint no-unused-vars: 0 no-empty-function: 0 */
5
- export default class CoreInterface {
6
- constructor(schema) {
7
- this.setSchema(schema);
8
- }
9
- get rootSchema() {
10
- return this.__rootSchema;
11
- }
12
- set rootSchema(rootSchema) {
13
- if (rootSchema == null) {
14
- return;
15
- }
16
- this.__rootSchema = compileSchema(rootSchema);
17
- }
18
- each(data, callback, schema = this.rootSchema, pointer = "#") {
19
- throw new Error("function 'each' is not implemented");
20
- }
21
- validate(data, schema = this.rootSchema, pointer = "#") {
22
- throw new Error("function 'validate' is not implemented");
23
- }
24
- isValid(data, schema = this.rootSchema, pointer = "#") {
25
- throw new Error("function 'isValid' is not implemented");
26
- }
27
- resolveAnyOf(data, schema, pointer = "#") {
28
- return resolveAnyOf(this, data, schema, pointer);
29
- }
30
- resolveAllOf(data, schema, pointer = "#") {
31
- return resolveAllOf(this, data, schema, pointer);
32
- }
33
- resolveRef(schema) {
34
- throw new Error("function 'resolveRef' is not implemented");
35
- }
36
- resolveOneOf(data, schema, pointer = "#") {
37
- throw new Error("function 'resolveOneOf' is not implemented");
38
- }
39
- getSchema(pointer, data, schema = this.rootSchema) {
40
- throw new Error("function 'getSchema' is not implemented");
41
- }
42
- getTemplate(data, schema = this.rootSchema) {
43
- throw new Error("function 'getTemplate' is not implemented");
44
- }
45
- setSchema(schema) {
46
- this.rootSchema = schema;
47
- }
48
- step(key, schema, data, pointer = "#") {
49
- throw new Error("function 'step' is not implemented");
50
- }
51
- }
@@ -1,52 +0,0 @@
1
- import CoreInterface from "./CoreInterface";
2
- import step from "../step";
3
- import validate from "../validate";
4
- import resolveOneOf from "../resolveOneOf.strict";
5
- import resolveRef from "../resolveRef.strict";
6
- import getTemplate from "../getTemplate";
7
- import getSchema from "../getSchema";
8
- import each from "../each";
9
- import compileSchema from "../compileSchema";
10
- import remotes from "../../remotes";
11
- import draft04 from "../../remotes/draft04.json";
12
- // @ts-ignore
13
- remotes["http://json-schema.org/draft-04/schema"] = compileSchema(draft04);
14
- import TYPE_KEYWORD_MAPPING from "../validation/typeKeywordMapping";
15
- import KEYWORDS from "../validation/keyword";
16
- import TYPES from "../validation/type";
17
- import FORMATS from "../validation/format";
18
- import ERRORS from "../validation/errors";
19
- export default class Draft04Core extends CoreInterface {
20
- constructor(schema) {
21
- super(schema);
22
- this.typeKeywords = JSON.parse(JSON.stringify(TYPE_KEYWORD_MAPPING));
23
- this.validateKeyword = Object.assign({}, KEYWORDS);
24
- this.validateType = Object.assign({}, TYPES);
25
- this.validateFormat = Object.assign({}, FORMATS);
26
- this.errors = Object.assign({}, ERRORS);
27
- }
28
- each(data, callback, schema = this.rootSchema, pointer = "#") {
29
- each(this, data, callback, schema, pointer);
30
- }
31
- validate(data, schema = this.rootSchema, pointer = "#") {
32
- return validate(this, data, schema, pointer);
33
- }
34
- isValid(data, schema = this.rootSchema, pointer = "#") {
35
- return this.validate(data, schema, pointer).length === 0;
36
- }
37
- resolveOneOf(data, schema, pointer) {
38
- return resolveOneOf(this, data, schema, pointer);
39
- }
40
- resolveRef(schema) {
41
- return resolveRef(schema, this.rootSchema);
42
- }
43
- getSchema(pointer, data, schema = this.rootSchema) {
44
- return getSchema(this, pointer, data, schema);
45
- }
46
- getTemplate(data, schema = this.rootSchema) {
47
- return getTemplate(this, data, schema);
48
- }
49
- step(key, schema, data, pointer = "#") {
50
- return step(this, key, schema, data, pointer);
51
- }
52
- }
@@ -1,51 +0,0 @@
1
- import CoreInterface from "./CoreInterface";
2
- import step from "../step";
3
- import validate from "../validate";
4
- import resolveOneOf from "../resolveOneOf.fuzzy";
5
- import resolveRef from "../resolveRef.withOverwrite";
6
- import getTemplate from "../getTemplate";
7
- import getSchema from "../getSchema";
8
- import each from "../each";
9
- import TYPE_KEYWORD_MAPPING from "../validation/typeKeywordMapping";
10
- import KEYWORDS from "../validation/keyword";
11
- import TYPES from "../validation/type";
12
- import FORMATS from "../validation/format";
13
- import ERRORS from "../validation/errors";
14
- export default class JsonEditorCore extends CoreInterface {
15
- constructor(schema) {
16
- super(schema);
17
- this.typeKeywords = JSON.parse(JSON.stringify(TYPE_KEYWORD_MAPPING));
18
- this.validateKeyword = Object.assign({}, KEYWORDS);
19
- // set properties required per default and prevent no duplicate errors.
20
- // This is required for fuzzy resolveOneOf
21
- // this.validateKeyword.properties = this.validateKeyword.propertiesRequired;
22
- // this.validateKeyword.required = this.validateKeyword.requiredNotEmpty;
23
- this.validateType = Object.assign({}, TYPES);
24
- this.validateFormat = Object.assign({}, FORMATS);
25
- this.errors = Object.assign({}, ERRORS);
26
- }
27
- each(data, callback, schema = this.rootSchema, pointer = "#") {
28
- each(this, data, callback, schema, pointer);
29
- }
30
- validate(data, schema = this.rootSchema, pointer = "#") {
31
- return validate(this, data, schema, pointer);
32
- }
33
- isValid(data, schema = this.rootSchema, pointer = "#") {
34
- return this.validate(data, schema, pointer).length === 0;
35
- }
36
- resolveOneOf(data, schema, pointer) {
37
- return resolveOneOf(this, data, schema, pointer);
38
- }
39
- resolveRef(schema) {
40
- return resolveRef(schema, this.rootSchema);
41
- }
42
- getSchema(pointer, data, schema = this.rootSchema) {
43
- return getSchema(this, pointer, data, schema);
44
- }
45
- getTemplate(data, schema = this.rootSchema) {
46
- return getTemplate(this, data, schema);
47
- }
48
- step(key, schema, data, pointer = "#") {
49
- return step(this, key, schema, data, pointer);
50
- }
51
- }
@@ -1,10 +0,0 @@
1
- export default {
2
- "http://json-schema.org/draft-04/schema": require("./draft04.json"),
3
- reset() {
4
- Object.keys(this).forEach(key => {
5
- if (typeof this[key] !== "function" && key !== "http://json-schema.org/draft-04/schema") {
6
- delete this[key];
7
- }
8
- });
9
- }
10
- };
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- "http://json-schema.org/draft-04/schema": any;
3
- reset(): void;
4
- };
5
- export default _default;
@@ -1,76 +0,0 @@
1
- /* eslint @typescript-eslint/no-unused-vars: "off" */
2
- import resolveRef from "../resolveRef.withOverwrite";
3
- import compileSchema from "../compileSchema";
4
- import resolveAnyOf from "../resolveAnyOf";
5
- import resolveAllOf from "../resolveAllOf";
6
- import { JSONSchema, JSONPointer, JSONError } from "../types";
7
-
8
-
9
- /* eslint no-unused-vars: 0 no-empty-function: 0 */
10
- export default class CoreInterface {
11
- __rootSchema: JSONSchema;
12
- errors;
13
- typeKeywords;
14
- validateFormat;
15
- validateKeyword;
16
- validateType;
17
-
18
- constructor(schema?: JSONSchema) {
19
- this.setSchema(schema);
20
- }
21
-
22
- get rootSchema() {
23
- return this.__rootSchema;
24
- }
25
-
26
- set rootSchema(rootSchema: JSONSchema) {
27
- if (rootSchema == null) {
28
- return;
29
- }
30
- this.__rootSchema = compileSchema(rootSchema);
31
- }
32
-
33
- each(data: any, callback, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
34
- throw new Error("function 'each' is not implemented");
35
- }
36
-
37
- validate(data: any, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#"): Array<JSONError> {
38
- throw new Error("function 'validate' is not implemented");
39
- }
40
-
41
- isValid(data: any, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#"): boolean {
42
- throw new Error("function 'isValid' is not implemented");
43
- }
44
-
45
- resolveAnyOf(data: any, schema: JSONSchema, pointer: JSONPointer = "#"): JSONSchema {
46
- return resolveAnyOf(this, data, schema, pointer);
47
- }
48
-
49
- resolveAllOf(data: any, schema: JSONSchema, pointer: JSONPointer = "#"): JSONSchema {
50
- return resolveAllOf(this, data, schema, pointer);
51
- }
52
-
53
- resolveRef(schema: JSONSchema): JSONSchema {
54
- throw new Error("function 'resolveRef' is not implemented");
55
- }
56
-
57
- resolveOneOf(data: any, schema: JSONSchema, pointer: JSONPointer = "#"): JSONSchema {
58
- throw new Error("function 'resolveOneOf' is not implemented");
59
- }
60
-
61
- getSchema(pointer: JSONPointer, data: any, schema: JSONSchema = this.rootSchema) {
62
- throw new Error("function 'getSchema' is not implemented");
63
- }
64
-
65
- getTemplate(data: any, schema: JSONSchema = this.rootSchema) {
66
- throw new Error("function 'getTemplate' is not implemented");
67
- }
68
-
69
- setSchema(schema: JSONSchema) {
70
- this.rootSchema = schema;
71
- }
72
-
73
- step(key: string, schema: JSONSchema, data: any, pointer: JSONPointer = "#"): JSONSchema {
74
- throw new Error("function 'step' is not implemented");
75
- }
76
- }
@@ -1,66 +0,0 @@
1
- import CoreInterface from "./CoreInterface";
2
- import step from "../step";
3
- import validate from "../validate";
4
- import resolveOneOf from "../resolveOneOf.strict";
5
- import resolveRef from "../resolveRef.strict";
6
- import getTemplate from "../getTemplate";
7
- import getSchema from "../getSchema";
8
- import each from "../each";
9
- import compileSchema from "../compileSchema";
10
- import { JSONSchema, JSONPointer } from "../types";
11
-
12
- import remotes from "../../remotes";
13
- import draft04 from "../../remotes/draft04.json";
14
- // @ts-ignore
15
- remotes["http://json-schema.org/draft-04/schema"] = compileSchema(draft04);
16
-
17
- import TYPE_KEYWORD_MAPPING from "../validation/typeKeywordMapping";
18
- import KEYWORDS from "../validation/keyword";
19
- import TYPES from "../validation/type";
20
- import FORMATS from "../validation/format";
21
- import ERRORS from "../validation/errors";
22
-
23
-
24
- export default class Draft04Core extends CoreInterface {
25
-
26
- constructor(schema?: JSONSchema) {
27
- super(schema);
28
- this.typeKeywords = JSON.parse(JSON.stringify(TYPE_KEYWORD_MAPPING));
29
- this.validateKeyword = Object.assign({}, KEYWORDS);
30
- this.validateType = Object.assign({}, TYPES);
31
- this.validateFormat = Object.assign({}, FORMATS);
32
- this.errors = Object.assign({}, ERRORS);
33
- }
34
-
35
- each(data: any, callback, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
36
- each(this, data, callback, schema, pointer);
37
- }
38
-
39
- validate(data: any, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
40
- return validate(this, data, schema, pointer);
41
- }
42
-
43
- isValid(data: any, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
44
- return this.validate(data, schema, pointer).length === 0;
45
- }
46
-
47
- resolveOneOf(data: any, schema: JSONSchema, pointer: JSONPointer) {
48
- return resolveOneOf(this, data, schema, pointer);
49
- }
50
-
51
- resolveRef(schema: JSONSchema) {
52
- return resolveRef(schema, this.rootSchema);
53
- }
54
-
55
- getSchema(pointer: JSONPointer, data: any, schema: JSONSchema = this.rootSchema) {
56
- return getSchema(this, pointer, data, schema);
57
- }
58
-
59
- getTemplate(data: any, schema: JSONSchema = this.rootSchema) {
60
- return getTemplate(this, data, schema);
61
- }
62
-
63
- step(key: string, schema: JSONSchema, data: any, pointer: JSONPointer = "#") {
64
- return step(this, key, schema, data, pointer);
65
- }
66
- }
@@ -1,64 +0,0 @@
1
- import CoreInterface from "./CoreInterface";
2
- import step from "../step";
3
- import validate from "../validate";
4
- import resolveOneOf from "../resolveOneOf.fuzzy";
5
- import resolveRef from "../resolveRef.withOverwrite";
6
- import getTemplate from "../getTemplate";
7
- import getSchema from "../getSchema";
8
- import each from "../each";
9
- import { JSONSchema, JSONPointer } from "../types";
10
-
11
- import TYPE_KEYWORD_MAPPING from "../validation/typeKeywordMapping";
12
- import KEYWORDS from "../validation/keyword";
13
- import TYPES from "../validation/type";
14
- import FORMATS from "../validation/format";
15
- import ERRORS from "../validation/errors";
16
-
17
-
18
- export default class JsonEditorCore extends CoreInterface {
19
-
20
- constructor(schema?: JSONSchema) {
21
- super(schema);
22
- this.typeKeywords = JSON.parse(JSON.stringify(TYPE_KEYWORD_MAPPING));
23
- this.validateKeyword = Object.assign({}, KEYWORDS);
24
- // set properties required per default and prevent no duplicate errors.
25
- // This is required for fuzzy resolveOneOf
26
- // this.validateKeyword.properties = this.validateKeyword.propertiesRequired;
27
- // this.validateKeyword.required = this.validateKeyword.requiredNotEmpty;
28
- this.validateType = Object.assign({}, TYPES);
29
- this.validateFormat = Object.assign({}, FORMATS);
30
- this.errors = Object.assign({}, ERRORS);
31
- }
32
-
33
- each(data: any, callback, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
34
- each(this, data, callback, schema, pointer);
35
- }
36
-
37
- validate(data: any, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
38
- return validate(this, data, schema, pointer);
39
- }
40
-
41
- isValid(data: any, schema: JSONSchema = this.rootSchema, pointer: JSONPointer = "#") {
42
- return this.validate(data, schema, pointer).length === 0;
43
- }
44
-
45
- resolveOneOf(data, schema: JSONSchema, pointer: JSONPointer) {
46
- return resolveOneOf(this, data, schema, pointer);
47
- }
48
-
49
- resolveRef(schema: JSONSchema) {
50
- return resolveRef(schema, this.rootSchema);
51
- }
52
-
53
- getSchema(pointer: JSONPointer, data: any, schema: JSONSchema = this.rootSchema) {
54
- return getSchema(this, pointer, data, schema);
55
- }
56
-
57
- getTemplate(data: any, schema: JSONSchema = this.rootSchema) {
58
- return getTemplate(this, data, schema);
59
- }
60
-
61
- step(key: string, schema: JSONSchema, data, pointer: JSONPointer = "#") {
62
- return step(this, key, schema, data, pointer);
63
- }
64
- }
package/remotes/index.ts DELETED
@@ -1,11 +0,0 @@
1
- export default {
2
- "http://json-schema.org/draft-04/schema": require("./draft04.json"),
3
-
4
- reset() {
5
- Object.keys(this).forEach(key => {
6
- if (typeof this[key] !== "function" && key !== "http://json-schema.org/draft-04/schema") {
7
- delete this[key];
8
- }
9
- });
10
- }
11
- };