@lionweb/validation 0.5.0 → 0.6.0-beta.2
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 +2 -0
- package/dist/diff/DiffResult.d.ts +9 -0
- package/dist/diff/DiffResult.d.ts.map +1 -0
- package/dist/diff/DiffResult.js +18 -0
- package/dist/diff/DiffResult.js.map +1 -0
- package/dist/diff/LionWebJsonDiff.d.ts +25 -0
- package/dist/diff/LionWebJsonDiff.d.ts.map +1 -0
- package/dist/diff/LionWebJsonDiff.js +205 -0
- package/dist/diff/LionWebJsonDiff.js.map +1 -0
- package/dist/diff/changes/Change.d.ts +16 -0
- package/dist/diff/changes/Change.d.ts.map +1 -0
- package/dist/diff/changes/Change.js +19 -0
- package/dist/diff/changes/Change.js.map +1 -0
- package/dist/diff/changes/ChunkChange.d.ts +43 -0
- package/dist/diff/changes/ChunkChange.d.ts.map +1 -0
- package/dist/diff/changes/ChunkChange.js +57 -0
- package/dist/diff/changes/ChunkChange.js.map +1 -0
- package/dist/diff/changes/ContainmentChange.d.ts +26 -0
- package/dist/diff/changes/ContainmentChange.d.ts.map +1 -0
- package/dist/diff/changes/ContainmentChange.js +34 -0
- package/dist/diff/changes/ContainmentChange.js.map +1 -0
- package/dist/diff/changes/NodeChange.d.ts +22 -0
- package/dist/diff/changes/NodeChange.d.ts.map +1 -0
- package/dist/diff/changes/NodeChange.js +24 -0
- package/dist/diff/changes/NodeChange.js.map +1 -0
- package/dist/diff/changes/PropertyChange.d.ts +23 -0
- package/dist/diff/changes/PropertyChange.d.ts.map +1 -0
- package/dist/diff/changes/PropertyChange.js +28 -0
- package/dist/diff/changes/PropertyChange.js.map +1 -0
- package/dist/diff/changes/ReferenceChange.d.ts +19 -0
- package/dist/diff/changes/ReferenceChange.d.ts.map +1 -0
- package/dist/diff/changes/ReferenceChange.js +25 -0
- package/dist/diff/changes/ReferenceChange.js.map +1 -0
- package/dist/diff/changes/index.d.ts +7 -0
- package/dist/diff/changes/index.d.ts.map +1 -0
- package/dist/diff/changes/index.js +7 -0
- package/dist/diff/changes/index.js.map +1 -0
- package/dist/diff/index.d.ts +4 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +4 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/issues/LanguageIssues.d.ts +1 -1
- package/dist/issues/LanguageIssues.d.ts.map +1 -1
- package/dist/issues/LanguageIssues.js.map +1 -1
- package/dist/issues/ReferenceIssues.d.ts +1 -1
- package/dist/issues/ReferenceIssues.d.ts.map +1 -1
- package/dist/issues/ReferenceIssues.js.map +1 -1
- package/dist/issues/SyntaxIssues.d.ts +1 -1
- package/dist/issues/SyntaxIssues.d.ts.map +1 -1
- package/dist/issues/SyntaxIssues.js +4 -4
- package/dist/issues/SyntaxIssues.js.map +1 -1
- package/dist/issues/ValidationIssue.d.ts +1 -1
- package/dist/issues/ValidationIssue.d.ts.map +1 -1
- package/dist/issues/ValidationIssue.js.map +1 -1
- package/dist/issues/index.d.ts +1 -1
- package/dist/issues/index.d.ts.map +1 -1
- package/dist/issues/index.js +1 -1
- package/dist/issues/index.js.map +1 -1
- package/dist/json/ChunkUtils.d.ts.map +1 -1
- package/dist/json/ChunkUtils.js.map +1 -1
- package/dist/json/JsonContext.d.ts.map +1 -0
- package/dist/json/JsonContext.js.map +1 -0
- package/dist/json/LanguageUtils.d.ts.map +1 -1
- package/dist/json/LanguageUtils.js.map +1 -1
- package/dist/json/LionWebJson.d.ts +10 -9
- package/dist/json/LionWebJson.d.ts.map +1 -1
- package/dist/json/LionWebJson.js +1 -0
- package/dist/json/LionWebJson.js.map +1 -1
- package/dist/json/LionWebJsonChunkWrapper.d.ts +7 -4
- package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -1
- package/dist/json/LionWebJsonChunkWrapper.js +48 -10
- package/dist/json/LionWebJsonChunkWrapper.js.map +1 -1
- package/dist/json/LionWebLanguageDefinition.d.ts.map +1 -1
- package/dist/json/LionWebLanguageDefinition.js +3 -3
- package/dist/json/LionWebLanguageDefinition.js.map +1 -1
- package/dist/json/NodeUtils.d.ts +5 -4
- package/dist/json/NodeUtils.d.ts.map +1 -1
- package/dist/json/NodeUtils.js +5 -2
- package/dist/json/NodeUtils.js.map +1 -1
- package/dist/json/index.d.ts +1 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +1 -0
- package/dist/json/index.js.map +1 -1
- package/dist/runners/FileUtils.d.ts.map +1 -1
- package/dist/runners/FileUtils.js.map +1 -1
- package/dist/runners/RunCheckFolder.js.map +1 -1
- package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
- package/dist/runners/RunCheckOneFile.js.map +1 -1
- package/dist/runners/RunCheckOneFileWithLanguage.js.map +1 -1
- package/dist/runners/RunLioncoreDiff.js +5 -5
- package/dist/runners/RunLioncoreDiff.js.map +1 -1
- package/dist/runners/Utils.d.ts.map +1 -1
- package/dist/runners/Utils.js +1 -1
- package/dist/runners/Utils.js.map +1 -1
- package/dist/runners/index.d.ts.map +1 -1
- package/dist/runners/index.js.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.js +6 -6
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageValidator.js +1 -1
- package/dist/validators/LionWebLanguageValidator.js.map +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebReferenceValidator.js +6 -6
- package/dist/validators/LionWebReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.js +21 -11
- package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
- package/dist/validators/LionWebValidator.d.ts.map +1 -1
- package/dist/validators/LionWebValidator.js.map +1 -1
- package/dist/validators/SimpleFieldValidator.d.ts +1 -1
- package/dist/validators/SimpleFieldValidator.d.ts.map +1 -1
- package/dist/validators/SimpleFieldValidator.js +1 -1
- package/dist/validators/SimpleFieldValidator.js.map +1 -1
- package/dist/validators/ValidationResult.d.ts.map +1 -1
- package/dist/validators/ValidationResult.js.map +1 -1
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js.map +1 -1
- package/package.json +5 -2
- package/src/diff/DiffResult.ts +21 -0
- package/src/diff/LionWebJsonDiff.ts +259 -0
- package/src/diff/changes/Change.ts +52 -0
- package/src/diff/changes/ChunkChange.ts +68 -0
- package/src/diff/changes/ContainmentChange.ts +34 -0
- package/src/diff/changes/NodeChange.ts +32 -0
- package/src/diff/changes/PropertyChange.ts +29 -0
- package/src/diff/changes/ReferenceChange.ts +24 -0
- package/src/diff/changes/index.ts +6 -0
- package/src/diff/index.ts +3 -0
- package/src/index.ts +5 -4
- package/src/issues/LanguageIssues.ts +61 -39
- package/src/issues/ReferenceIssues.ts +51 -29
- package/src/issues/SyntaxIssues.ts +38 -23
- package/src/issues/ValidationIssue.ts +7 -7
- package/src/issues/index.ts +5 -5
- package/src/json/ChunkUtils.ts +7 -11
- package/src/json/JsonContext.ts +31 -0
- package/src/json/LanguageUtils.ts +5 -6
- package/src/json/LionWebJson.ts +44 -43
- package/src/json/LionWebJsonChunkWrapper.ts +76 -29
- package/src/json/LionWebLanguageDefinition.ts +44 -49
- package/src/json/NodeUtils.ts +25 -19
- package/src/json/index.ts +7 -6
- package/src/json/std-builtins-copy.json +347 -349
- package/src/runners/FileUtils.ts +48 -49
- package/src/runners/RunCheckFolder.ts +3 -3
- package/src/runners/RunCheckFolderWithLanguage.ts +31 -30
- package/src/runners/RunCheckOneFile.ts +3 -3
- package/src/runners/RunCheckOneFileWithLanguage.ts +21 -19
- package/src/runners/RunLioncoreDiff.ts +15 -15
- package/src/runners/Utils.ts +24 -24
- package/src/runners/index.ts +2 -2
- package/src/validators/LionWebLanguageReferenceValidator.ts +63 -55
- package/src/validators/LionWebLanguageValidator.ts +11 -12
- package/src/validators/LionWebReferenceValidator.ts +90 -76
- package/src/validators/LionWebSyntaxValidator.ts +108 -99
- package/src/validators/LionWebValidator.ts +33 -33
- package/src/validators/SimpleFieldValidator.ts +33 -28
- package/src/validators/ValidationResult.ts +5 -6
- package/src/validators/index.ts +7 -7
- package/dist/diff/LionwebDiff.d.ts +0 -40
- package/dist/diff/LionwebDiff.d.ts.map +0 -1
- package/dist/diff/LionwebDiff.js +0 -158
- package/dist/diff/LionwebDiff.js.map +0 -1
- package/dist/issues/JsonContext.d.ts.map +0 -1
- package/dist/issues/JsonContext.js.map +0 -1
- package/src/diff/LionwebDiff.ts +0 -193
- package/src/issues/JsonContext.ts +0 -31
- /package/dist/{issues → json}/JsonContext.d.ts +0 -0
- /package/dist/{issues → json}/JsonContext.js +0 -0
|
@@ -3,38 +3,29 @@ import {
|
|
|
3
3
|
Syntax_PropertyMissingIssue,
|
|
4
4
|
Syntax_PropertyNullIssue,
|
|
5
5
|
Syntax_PropertyTypeIssue,
|
|
6
|
-
Syntax_PropertyUnknownIssue
|
|
7
|
-
} from "../issues/SyntaxIssues.js"
|
|
8
|
-
import { SimpleFieldValidator, ValidatorFunction } from "./SimpleFieldValidator.js"
|
|
9
|
-
import { JsonContext } from "
|
|
10
|
-
import { ValidationResult } from "./ValidationResult.js"
|
|
6
|
+
Syntax_PropertyUnknownIssue,
|
|
7
|
+
} from "../issues/SyntaxIssues.js"
|
|
8
|
+
import { SimpleFieldValidator, ValidatorFunction } from "./SimpleFieldValidator.js"
|
|
9
|
+
import { JsonContext } from "../json/JsonContext.js"
|
|
10
|
+
import { ValidationResult } from "./ValidationResult.js"
|
|
11
11
|
|
|
12
|
-
export type UnknownObjectType = { [key: string]: unknown }
|
|
12
|
+
export type UnknownObjectType = { [key: string]: unknown }
|
|
13
13
|
|
|
14
|
-
export type PropertyType =
|
|
15
|
-
"string"
|
|
16
|
-
| "number"
|
|
17
|
-
| "bigint"
|
|
18
|
-
| "boolean"
|
|
19
|
-
| "symbol"
|
|
20
|
-
| "undefined"
|
|
21
|
-
| "object"
|
|
22
|
-
| "function"
|
|
23
|
-
| "array";
|
|
14
|
+
export type PropertyType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "array"
|
|
24
15
|
|
|
25
16
|
export type PropertyDefinition = {
|
|
26
17
|
/**
|
|
27
18
|
* The property name
|
|
28
19
|
*/
|
|
29
|
-
property: string
|
|
20
|
+
property: string
|
|
30
21
|
/**
|
|
31
22
|
* The expected type of the property value
|
|
32
23
|
*/
|
|
33
|
-
expectedType: PropertyType
|
|
24
|
+
expectedType: PropertyType
|
|
34
25
|
/**
|
|
35
26
|
* Whether the property value is allowed to be null
|
|
36
27
|
*/
|
|
37
|
-
mayBeNull: boolean
|
|
28
|
+
mayBeNull: boolean
|
|
38
29
|
/**
|
|
39
30
|
* If the property type is correct, check its value further with this function.
|
|
40
31
|
* Will, only be called if `this.recursive === true`.
|
|
@@ -42,30 +33,30 @@ export type PropertyDefinition = {
|
|
|
42
33
|
* @param obj
|
|
43
34
|
* @param ctx
|
|
44
35
|
*/
|
|
45
|
-
validateValue?: ValidatorFunction
|
|
46
|
-
}
|
|
36
|
+
validateValue?: ValidatorFunction
|
|
37
|
+
}
|
|
47
38
|
|
|
48
39
|
// Make boolean argument more readable.
|
|
49
|
-
const MAY_BE_NULL = true
|
|
50
|
-
const NOT_NULL = false
|
|
40
|
+
const MAY_BE_NULL = true
|
|
41
|
+
const NOT_NULL = false
|
|
51
42
|
|
|
52
43
|
/**
|
|
53
44
|
* LionWebCheck can chack whether objects are LionWeb JSON objects.
|
|
54
45
|
* The check can be on a single object, or recursively on an object and its children.
|
|
55
46
|
*/
|
|
56
47
|
export class LionWebSyntaxValidator {
|
|
57
|
-
validationResult: ValidationResult
|
|
58
|
-
simpleFieldValidator: SimpleFieldValidator
|
|
48
|
+
validationResult: ValidationResult
|
|
49
|
+
simpleFieldValidator: SimpleFieldValidator
|
|
59
50
|
/**
|
|
60
51
|
* When true, each function will work recursively on the given object.
|
|
61
52
|
* When false, will only check the given object.
|
|
62
53
|
* Metapointers are always checked as part of the object, disregarding the va;lue of `recursive`.
|
|
63
54
|
*/
|
|
64
|
-
recursive: boolean = true
|
|
55
|
+
recursive: boolean = true
|
|
65
56
|
|
|
66
57
|
constructor(validationResult: ValidationResult) {
|
|
67
|
-
this.validationResult = validationResult
|
|
68
|
-
this.simpleFieldValidator = new SimpleFieldValidator(this.validationResult)
|
|
58
|
+
this.validationResult = validationResult
|
|
59
|
+
this.simpleFieldValidator = new SimpleFieldValidator(this.validationResult)
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
/**
|
|
@@ -74,27 +65,31 @@ export class LionWebSyntaxValidator {
|
|
|
74
65
|
* @param obj
|
|
75
66
|
*/
|
|
76
67
|
validate(obj: unknown) {
|
|
77
|
-
this.validateLwChunk(obj, new JsonContext(null, ["$"]))
|
|
68
|
+
this.validateLwChunk(obj, new JsonContext(null, ["$"]))
|
|
78
69
|
}
|
|
79
70
|
|
|
80
71
|
validateLwChunk = (obj: unknown, ctx: JsonContext): void => {
|
|
81
72
|
const expected: PropertyDefinition[] = [
|
|
82
|
-
{
|
|
73
|
+
{
|
|
74
|
+
property: "serializationFormatVersion",
|
|
75
|
+
expectedType: "string",
|
|
76
|
+
mayBeNull: NOT_NULL,
|
|
77
|
+
validateValue: this.simpleFieldValidator.validateSerializationFormatVersion,
|
|
78
|
+
},
|
|
83
79
|
{ property: "languages", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.validateLwUsedLanguage },
|
|
84
80
|
{ property: "nodes", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.validateLwNode },
|
|
85
|
-
]
|
|
86
|
-
this.propertyChecks(obj, expected, ctx)
|
|
81
|
+
]
|
|
82
|
+
this.propertyChecks(obj, expected, ctx)
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
validateLwUsedLanguage = (obj: unknown, ctx: JsonContext): void => {
|
|
90
86
|
const expected: PropertyDefinition[] = [
|
|
91
87
|
{ property: "key", expectedType: "string", mayBeNull: NOT_NULL, validateValue: this.simpleFieldValidator.validateKey },
|
|
92
|
-
{ property: "version", expectedType: "string", mayBeNull: NOT_NULL, validateValue: this.simpleFieldValidator.validateVersion }
|
|
93
|
-
]
|
|
88
|
+
{ property: "version", expectedType: "string", mayBeNull: NOT_NULL, validateValue: this.simpleFieldValidator.validateVersion },
|
|
89
|
+
]
|
|
94
90
|
// if (this.checkType(obj, "object", ctx)) {
|
|
95
|
-
|
|
91
|
+
this.propertyChecks(obj, expected, ctx)
|
|
96
92
|
// }
|
|
97
|
-
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
validateLwNode = (obj: unknown, ctx: JsonContext): void => {
|
|
@@ -106,13 +101,13 @@ export class LionWebSyntaxValidator {
|
|
|
106
101
|
{ property: "references", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.validateLwReference },
|
|
107
102
|
{ property: "annotations", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.validateLwAnnotation },
|
|
108
103
|
{ property: "parent", expectedType: "string", mayBeNull: MAY_BE_NULL, validateValue: this.simpleFieldValidator.validateId },
|
|
109
|
-
]
|
|
110
|
-
this.propertyChecks(obj, expected, ctx)
|
|
104
|
+
]
|
|
105
|
+
this.propertyChecks(obj, expected, ctx)
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
validateLwAnnotation = (obj: unknown, context: JsonContext) => {
|
|
114
109
|
if (this.checkType(obj, "string", context)) {
|
|
115
|
-
this.simpleFieldValidator.validateId(obj as string, context)
|
|
110
|
+
this.simpleFieldValidator.validateId(obj as string, context)
|
|
116
111
|
}
|
|
117
112
|
}
|
|
118
113
|
|
|
@@ -120,8 +115,8 @@ export class LionWebSyntaxValidator {
|
|
|
120
115
|
const expected: PropertyDefinition[] = [
|
|
121
116
|
{ property: "property", expectedType: "object", mayBeNull: NOT_NULL, validateValue: this.validateLwMetaPointer },
|
|
122
117
|
{ property: "value", expectedType: "string", mayBeNull: MAY_BE_NULL },
|
|
123
|
-
]
|
|
124
|
-
this.propertyChecks(obj, expected, ctx)
|
|
118
|
+
]
|
|
119
|
+
this.propertyChecks(obj, expected, ctx)
|
|
125
120
|
// TODO: hack for keys in M2 models
|
|
126
121
|
// if ((obj as any)["property"].key === "IKeyed-key") {
|
|
127
122
|
// // console.log("CHECKING KEY");
|
|
@@ -132,23 +127,28 @@ export class LionWebSyntaxValidator {
|
|
|
132
127
|
validateLwMetaPointer = (obj: unknown, ctx: JsonContext): void => {
|
|
133
128
|
const expected: PropertyDefinition[] = [
|
|
134
129
|
{ property: "key", expectedType: "string", mayBeNull: NOT_NULL, validateValue: this.simpleFieldValidator.validateKey },
|
|
135
|
-
{
|
|
130
|
+
{
|
|
131
|
+
property: "version",
|
|
132
|
+
expectedType: "string",
|
|
133
|
+
mayBeNull: MAY_BE_NULL,
|
|
134
|
+
validateValue: this.simpleFieldValidator.validateVersion,
|
|
135
|
+
},
|
|
136
136
|
{ property: "language", expectedType: "string", mayBeNull: MAY_BE_NULL, validateValue: this.simpleFieldValidator.validateKey },
|
|
137
|
-
]
|
|
138
|
-
this.propertyChecks(obj, expected, ctx)
|
|
137
|
+
]
|
|
138
|
+
this.propertyChecks(obj, expected, ctx)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
validateLwChild = (obj: unknown, ctx: JsonContext): void => {
|
|
142
142
|
const expected: PropertyDefinition[] = [
|
|
143
143
|
{ property: "containment", expectedType: "object", mayBeNull: NOT_NULL, validateValue: this.validateLwMetaPointer },
|
|
144
|
-
{ property: "children", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.checkChild }
|
|
145
|
-
]
|
|
146
|
-
this.propertyChecks(obj, expected, ctx)
|
|
144
|
+
{ property: "children", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.checkChild },
|
|
145
|
+
]
|
|
146
|
+
this.propertyChecks(obj, expected, ctx)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
private checkChild = (obj: unknown, context: JsonContext) => {
|
|
150
150
|
if (this.checkType(obj, "string", context)) {
|
|
151
|
-
this.simpleFieldValidator.validateId(obj as string, context)
|
|
151
|
+
this.simpleFieldValidator.validateId(obj as string, context)
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -156,30 +156,30 @@ export class LionWebSyntaxValidator {
|
|
|
156
156
|
*/
|
|
157
157
|
private checkType = (obj: unknown, expectedType: PropertyType, context: JsonContext): boolean => {
|
|
158
158
|
if (obj === null || obj === undefined) {
|
|
159
|
-
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, "obj", expectedType, typeof obj))
|
|
160
|
-
return false
|
|
159
|
+
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, "obj", expectedType, typeof obj))
|
|
160
|
+
return false
|
|
161
161
|
} else if (typeof obj !== expectedType) {
|
|
162
162
|
// TODO Better context: where does obj come from
|
|
163
|
-
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, "obj", expectedType, typeof obj))
|
|
164
|
-
return false
|
|
163
|
+
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, "obj", expectedType, typeof obj))
|
|
164
|
+
return false
|
|
165
165
|
}
|
|
166
|
-
return true
|
|
166
|
+
return true
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
validateLwReference = (obj: unknown, ctx: JsonContext): void => {
|
|
170
170
|
const expected: PropertyDefinition[] = [
|
|
171
171
|
{ property: "reference", expectedType: "object", mayBeNull: NOT_NULL, validateValue: this.validateLwMetaPointer },
|
|
172
|
-
{ property: "targets", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.validateLwReferenceTarget }
|
|
173
|
-
]
|
|
174
|
-
this.propertyChecks(obj, expected, ctx)
|
|
172
|
+
{ property: "targets", expectedType: "array", mayBeNull: NOT_NULL, validateValue: this.validateLwReferenceTarget },
|
|
173
|
+
]
|
|
174
|
+
this.propertyChecks(obj, expected, ctx)
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
validateLwReferenceTarget = (obj: unknown, ctx: JsonContext): void => {
|
|
178
178
|
const expected: PropertyDefinition[] = [
|
|
179
179
|
{ property: "resolveInfo", expectedType: "string", mayBeNull: MAY_BE_NULL },
|
|
180
|
-
{ property: "reference", expectedType: "string", mayBeNull: MAY_BE_NULL, validateValue: this.simpleFieldValidator.validateId }
|
|
181
|
-
]
|
|
182
|
-
this.propertyChecks(obj, expected, ctx)
|
|
180
|
+
{ property: "reference", expectedType: "string", mayBeNull: MAY_BE_NULL, validateValue: this.simpleFieldValidator.validateId },
|
|
181
|
+
]
|
|
182
|
+
this.propertyChecks(obj, expected, ctx)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
@@ -191,36 +191,40 @@ export class LionWebSyntaxValidator {
|
|
|
191
191
|
*/
|
|
192
192
|
propertyChecks(obj: unknown, propDefs: PropertyDefinition[], context: JsonContext): void {
|
|
193
193
|
if (!this.checkType(obj, "object", context)) {
|
|
194
|
-
return
|
|
194
|
+
return
|
|
195
195
|
}
|
|
196
|
-
const object = obj as UnknownObjectType
|
|
197
|
-
const allProperties: string[] = []
|
|
198
|
-
propDefs.forEach(
|
|
196
|
+
const object = obj as UnknownObjectType
|
|
197
|
+
const allProperties: string[] = []
|
|
198
|
+
propDefs.forEach(propDef => {
|
|
199
199
|
if (propDef.property === "key") {
|
|
200
200
|
// console.log("CHECKING KEY of " + JSON.stringify(obj))
|
|
201
201
|
}
|
|
202
|
-
if (
|
|
203
|
-
|
|
202
|
+
if (
|
|
203
|
+
this.checkPropertyType(object, propDef.property, propDef.expectedType, propDef.mayBeNull, context.concat(propDef.property))
|
|
204
|
+
) {
|
|
205
|
+
const propValue = object[propDef.property]
|
|
204
206
|
if (this.recursive && propDef.expectedType === "array" && Array.isArray(propValue) && !!propDef.validateValue) {
|
|
205
207
|
propValue.forEach((arrayItem: unknown, index: number) => {
|
|
206
208
|
if (arrayItem === null) {
|
|
207
|
-
this.validationResult.issue(
|
|
209
|
+
this.validationResult.issue(
|
|
210
|
+
new Syntax_ArrayContainsNull_Issue(context.concat(propDef.property, index), propDef.property, index),
|
|
211
|
+
)
|
|
208
212
|
} else {
|
|
209
|
-
if (propDef.validateValue !== null && propDef.validateValue !== undefined
|
|
210
|
-
propDef.validateValue(arrayItem, context.concat(propDef.property, index))
|
|
213
|
+
if (propDef.validateValue !== null && propDef.validateValue !== undefined) {
|
|
214
|
+
propDef.validateValue(arrayItem, context.concat(propDef.property, index))
|
|
211
215
|
} else {
|
|
212
216
|
// TODO: give an error, whih ine?
|
|
213
217
|
}
|
|
214
218
|
}
|
|
215
|
-
})
|
|
219
|
+
})
|
|
216
220
|
} else if (propDef.validateValue !== null && propDef.validateValue !== undefined) {
|
|
217
221
|
// propValue is niot an array, so it should be aa string
|
|
218
|
-
propDef.validateValue(propValue as string, context.concat(propDef.property))
|
|
222
|
+
propDef.validateValue(propValue as string, context.concat(propDef.property))
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
|
-
allProperties.push(propDef.property)
|
|
222
|
-
})
|
|
223
|
-
this.checkStrayProperties(object, allProperties, context)
|
|
225
|
+
allProperties.push(propDef.property)
|
|
226
|
+
})
|
|
227
|
+
this.checkStrayProperties(object, allProperties, context)
|
|
224
228
|
}
|
|
225
229
|
|
|
226
230
|
/**
|
|
@@ -230,18 +234,17 @@ export class LionWebSyntaxValidator {
|
|
|
230
234
|
* @param context
|
|
231
235
|
*/
|
|
232
236
|
checkStrayProperties(obj: UnknownObjectType, properties: string[], context: JsonContext) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
own.forEach((ownProp) => {
|
|
237
|
+
const own = Object.getOwnPropertyNames(obj)
|
|
238
|
+
own.forEach(ownProp => {
|
|
236
239
|
if (!properties.includes(ownProp)) {
|
|
237
|
-
this.validationResult.issue(new Syntax_PropertyUnknownIssue(context, ownProp))
|
|
240
|
+
this.validationResult.issue(new Syntax_PropertyUnknownIssue(context, ownProp))
|
|
238
241
|
}
|
|
239
|
-
})
|
|
240
|
-
properties.forEach(
|
|
242
|
+
})
|
|
243
|
+
properties.forEach(prop => {
|
|
241
244
|
if (!own.includes(prop)) {
|
|
242
|
-
this.validationResult.issue(new Syntax_PropertyMissingIssue(context, prop))
|
|
245
|
+
this.validationResult.issue(new Syntax_PropertyMissingIssue(context, prop))
|
|
243
246
|
}
|
|
244
|
-
})
|
|
247
|
+
})
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
/**
|
|
@@ -251,49 +254,55 @@ export class LionWebSyntaxValidator {
|
|
|
251
254
|
* @param expectedType
|
|
252
255
|
* @param context
|
|
253
256
|
*/
|
|
254
|
-
checkPropertyType = (
|
|
257
|
+
checkPropertyType = (
|
|
258
|
+
obj: UnknownObjectType,
|
|
259
|
+
prop: string,
|
|
260
|
+
expectedType: PropertyType,
|
|
261
|
+
mayBeNull: boolean,
|
|
262
|
+
context: JsonContext,
|
|
263
|
+
): boolean => {
|
|
255
264
|
if (prop === "key") {
|
|
256
265
|
// console.log(" checking type of key " + JSON.stringify(obj));
|
|
257
266
|
}
|
|
258
267
|
if (obj[prop] === undefined || obj[prop] === null) {
|
|
259
268
|
if (!mayBeNull) {
|
|
260
|
-
this.validationResult.issue(new Syntax_PropertyNullIssue(context, prop))
|
|
261
|
-
return false
|
|
269
|
+
this.validationResult.issue(new Syntax_PropertyNullIssue(context, prop))
|
|
270
|
+
return false
|
|
262
271
|
} else {
|
|
263
|
-
return true
|
|
272
|
+
return true
|
|
264
273
|
}
|
|
265
274
|
} else {
|
|
266
|
-
const actualType = typeof obj[prop]
|
|
275
|
+
const actualType = typeof obj[prop]
|
|
267
276
|
if (expectedType !== actualType) {
|
|
268
277
|
if (expectedType === "array" && actualType === "object") {
|
|
269
278
|
// typeof returns an object for an array, so we need to check this separately.
|
|
270
279
|
if (!Array.isArray(obj[prop])) {
|
|
271
|
-
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, prop, "array", typeof obj[prop]))
|
|
272
|
-
return false
|
|
280
|
+
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, prop, "array", typeof obj[prop]))
|
|
281
|
+
return false
|
|
273
282
|
} else {
|
|
274
|
-
return true
|
|
283
|
+
return true
|
|
275
284
|
}
|
|
276
285
|
} else {
|
|
277
|
-
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, prop, expectedType, actualType))
|
|
278
|
-
return false
|
|
286
|
+
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, prop, expectedType, actualType))
|
|
287
|
+
return false
|
|
279
288
|
}
|
|
280
289
|
} else {
|
|
281
290
|
if (expectedType === "object") {
|
|
282
291
|
// typeof returns an object for an array, so we need to check this separately.
|
|
283
292
|
if (Array.isArray(obj[prop])) {
|
|
284
|
-
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, prop, expectedType, "array"))
|
|
285
|
-
return false
|
|
293
|
+
this.validationResult.issue(new Syntax_PropertyTypeIssue(context, prop, expectedType, "array"))
|
|
294
|
+
return false
|
|
286
295
|
}
|
|
287
296
|
}
|
|
288
297
|
}
|
|
289
298
|
}
|
|
290
|
-
return true
|
|
299
|
+
return true
|
|
291
300
|
}
|
|
292
301
|
}
|
|
293
302
|
|
|
294
|
-
export function SyntaxValidator(jsonChunk:unknown): ValidationResult {
|
|
295
|
-
const validationResult = new ValidationResult()
|
|
296
|
-
const syntaxValidator = new LionWebSyntaxValidator(validationResult)
|
|
297
|
-
syntaxValidator.validate(jsonChunk)
|
|
298
|
-
return validationResult
|
|
303
|
+
export function SyntaxValidator(jsonChunk: unknown): ValidationResult {
|
|
304
|
+
const validationResult = new ValidationResult()
|
|
305
|
+
const syntaxValidator = new LionWebSyntaxValidator(validationResult)
|
|
306
|
+
syntaxValidator.validate(jsonChunk)
|
|
307
|
+
return validationResult
|
|
299
308
|
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { LionWebJsonChunk } from "../json/LionWebJson.js"
|
|
2
|
-
import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js"
|
|
3
|
-
import { LionWebLanguageDefinition } from "../json/LionWebLanguageDefinition.js"
|
|
4
|
-
import { LionWebLanguageReferenceValidator } from "./LionWebLanguageReferenceValidator.js"
|
|
5
|
-
import { LionWebReferenceValidator } from "./LionWebReferenceValidator.js"
|
|
6
|
-
import { LionWebSyntaxValidator } from "./LionWebSyntaxValidator.js"
|
|
7
|
-
import { ValidationResult } from "./ValidationResult.js"
|
|
1
|
+
import { LionWebJsonChunk } from "../json/LionWebJson.js"
|
|
2
|
+
import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js"
|
|
3
|
+
import { LionWebLanguageDefinition } from "../json/LionWebLanguageDefinition.js"
|
|
4
|
+
import { LionWebLanguageReferenceValidator } from "./LionWebLanguageReferenceValidator.js"
|
|
5
|
+
import { LionWebReferenceValidator } from "./LionWebReferenceValidator.js"
|
|
6
|
+
import { LionWebSyntaxValidator } from "./LionWebSyntaxValidator.js"
|
|
7
|
+
import { ValidationResult } from "./ValidationResult.js"
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Combined validator that calls all available validators.
|
|
11
11
|
* Will stop when one validator fails.
|
|
12
12
|
*/
|
|
13
13
|
export class LionWebValidator {
|
|
14
|
-
object: unknown
|
|
15
|
-
language: LionWebLanguageDefinition | null = null
|
|
14
|
+
object: unknown
|
|
15
|
+
language: LionWebLanguageDefinition | null = null
|
|
16
16
|
|
|
17
|
-
chunk: unknown
|
|
18
|
-
validationResult: ValidationResult
|
|
19
|
-
syntaxValidator: LionWebSyntaxValidator
|
|
20
|
-
referenceValidator: LionWebReferenceValidator
|
|
21
|
-
syntaxCorrect: boolean = false
|
|
22
|
-
referencesCorrect: boolean = false
|
|
17
|
+
chunk: unknown
|
|
18
|
+
validationResult: ValidationResult
|
|
19
|
+
syntaxValidator: LionWebSyntaxValidator
|
|
20
|
+
referenceValidator: LionWebReferenceValidator
|
|
21
|
+
syntaxCorrect: boolean = false
|
|
22
|
+
referencesCorrect: boolean = false
|
|
23
23
|
|
|
24
24
|
constructor(json: unknown, lang: LionWebLanguageDefinition | null) {
|
|
25
|
-
this.object = json
|
|
26
|
-
this.language =lang
|
|
27
|
-
this.validationResult = new ValidationResult()
|
|
28
|
-
this.syntaxValidator = new LionWebSyntaxValidator(this.validationResult)
|
|
29
|
-
this.referenceValidator = new LionWebReferenceValidator(this.validationResult)
|
|
25
|
+
this.object = json
|
|
26
|
+
this.language = lang
|
|
27
|
+
this.validationResult = new ValidationResult()
|
|
28
|
+
this.syntaxValidator = new LionWebSyntaxValidator(this.validationResult)
|
|
29
|
+
this.referenceValidator = new LionWebReferenceValidator(this.validationResult)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
validateAll() {
|
|
33
|
-
this.validateSyntax()
|
|
34
|
-
this.validateReferences()
|
|
35
|
-
this.validateForLanguage()
|
|
33
|
+
this.validateSyntax()
|
|
34
|
+
this.validateReferences()
|
|
35
|
+
this.validateForLanguage()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
validateSyntax() {
|
|
39
|
-
this.syntaxValidator.recursive = true
|
|
40
|
-
this.syntaxValidator.validate(this.object)
|
|
41
|
-
this.syntaxCorrect = !this.validationResult.hasErrors()
|
|
39
|
+
this.syntaxValidator.recursive = true
|
|
40
|
+
this.syntaxValidator.validate(this.object)
|
|
41
|
+
this.syntaxCorrect = !this.validationResult.hasErrors()
|
|
42
42
|
if (this.syntaxCorrect) {
|
|
43
|
-
this.chunk = new LionWebJsonChunkWrapper(this.object as LionWebJsonChunk)
|
|
43
|
+
this.chunk = new LionWebJsonChunkWrapper(this.object as LionWebJsonChunk)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
validateReferences(): void {
|
|
48
48
|
if (!this.syntaxCorrect) {
|
|
49
49
|
// console.log("validateReferences not executed because there are syntax errors.")
|
|
50
|
-
return
|
|
50
|
+
return
|
|
51
51
|
}
|
|
52
52
|
// when syntax is correct we know the chunk is actually a chunk!
|
|
53
|
-
this.referenceValidator.validate(this.chunk as LionWebJsonChunkWrapper)
|
|
53
|
+
this.referenceValidator.validate(this.chunk as LionWebJsonChunkWrapper)
|
|
54
54
|
this.referencesCorrect = !this.validationResult.hasErrors()
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
validateForLanguage(): void {
|
|
58
58
|
if (!this.syntaxCorrect) {
|
|
59
59
|
// console.log("validateForLanguage not executed because there are syntax errors.")
|
|
60
|
-
return
|
|
60
|
+
return
|
|
61
61
|
}
|
|
62
62
|
if (!this.referencesCorrect) {
|
|
63
63
|
// console.log("validateForLanguage not executed because there are reference errors.")
|
|
64
|
-
return
|
|
64
|
+
return
|
|
65
65
|
}
|
|
66
66
|
if (this.language !== null && this.language !== undefined) {
|
|
67
|
-
const languageReferenceValidator = new LionWebLanguageReferenceValidator(this.validationResult, this.language)
|
|
67
|
+
const languageReferenceValidator = new LionWebLanguageReferenceValidator(this.validationResult, this.language)
|
|
68
68
|
// when syntax is correct we know the chunk is actually a chunk!
|
|
69
|
-
languageReferenceValidator.validate(this.chunk as LionWebJsonChunkWrapper)
|
|
69
|
+
languageReferenceValidator.validate(this.chunk as LionWebJsonChunkWrapper)
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { Language_PropertyValue_Issue } from "../issues/LanguageIssues.js"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Language_PropertyValue_Issue } from "../issues/LanguageIssues.js"
|
|
2
|
+
import {
|
|
3
|
+
Syntax_IdFormat_Issue,
|
|
4
|
+
Syntax_KeyFormat_Issue,
|
|
5
|
+
Syntax_SerializationFormatVersion_Issue,
|
|
6
|
+
Syntax_VersionFormat_Issue,
|
|
7
|
+
} from "../issues/SyntaxIssues.js"
|
|
8
|
+
import { JsonContext } from "../json/JsonContext.js"
|
|
9
|
+
import { LionWebJsonProperty } from "../json/LionWebJson.js"
|
|
10
|
+
import { ValidationResult } from "./ValidationResult.js"
|
|
6
11
|
|
|
7
|
-
export type ValidatorFunction = <T>(obj: T, ctx: JsonContext) => void
|
|
12
|
+
export type ValidatorFunction = <T>(obj: T, ctx: JsonContext) => void
|
|
8
13
|
|
|
9
14
|
export class SimpleFieldValidator {
|
|
10
|
-
validationResult: ValidationResult
|
|
15
|
+
validationResult: ValidationResult
|
|
11
16
|
|
|
12
17
|
constructor(validationResult: ValidationResult) {
|
|
13
|
-
this.validationResult = validationResult
|
|
18
|
+
this.validationResult = validationResult
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
/**
|
|
@@ -21,12 +26,12 @@ export class SimpleFieldValidator {
|
|
|
21
26
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
27
|
validateId: ValidatorFunction = <String>(id: String, context: JsonContext): void => {
|
|
23
28
|
if (id === null || id === undefined) {
|
|
24
|
-
return
|
|
29
|
+
return
|
|
25
30
|
}
|
|
26
|
-
const idString: string = id.toString()
|
|
27
|
-
const egexp = /^[a-zA-Z0-9$_-][a-zA-Z0-9$_-]
|
|
31
|
+
const idString: string = id.toString()
|
|
32
|
+
const egexp = /^[a-zA-Z0-9$_-][a-zA-Z0-9$_-]*$/
|
|
28
33
|
if (!egexp.test(idString)) {
|
|
29
|
-
this.validationResult.issue(new Syntax_IdFormat_Issue(context, idString))
|
|
34
|
+
this.validationResult.issue(new Syntax_IdFormat_Issue(context, idString))
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
@@ -36,55 +41,55 @@ export class SimpleFieldValidator {
|
|
|
36
41
|
* @param context The context for the error message in errors.
|
|
37
42
|
* @return true if `key` is a correct LionWeb key.
|
|
38
43
|
*/
|
|
39
|
-
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
40
45
|
validateKey: ValidatorFunction = <String>(key: String, context: JsonContext): void => {
|
|
41
46
|
if (key === undefined || key === null) {
|
|
42
|
-
this.validationResult.issue(new Syntax_KeyFormat_Issue(context, "null-or-undefined"))
|
|
47
|
+
this.validationResult.issue(new Syntax_KeyFormat_Issue(context, "null-or-undefined"))
|
|
43
48
|
}
|
|
44
|
-
const keyString: string = "" + key
|
|
45
|
-
const egexp = /^[a-zA-Z0-9$_-][a-zA-Z$_0-9-]
|
|
49
|
+
const keyString: string = "" + key
|
|
50
|
+
const egexp = /^[a-zA-Z0-9$_-][a-zA-Z$_0-9-]*$/
|
|
46
51
|
if (!egexp.test(keyString)) {
|
|
47
|
-
this.validationResult.issue(new Syntax_KeyFormat_Issue(context, keyString))
|
|
52
|
+
this.validationResult.issue(new Syntax_KeyFormat_Issue(context, keyString))
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
52
57
|
validateVersion: ValidatorFunction = <String>(version: String, context: JsonContext): void => {
|
|
53
|
-
const versionString: string = "" + version
|
|
58
|
+
const versionString: string = "" + version
|
|
54
59
|
if (versionString.length === 0) {
|
|
55
|
-
this.validationResult.issue(new Syntax_VersionFormat_Issue(context, versionString))
|
|
60
|
+
this.validationResult.issue(new Syntax_VersionFormat_Issue(context, versionString))
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
validateBoolean = (property: LionWebJsonProperty, propName: string, context: JsonContext): void => {
|
|
60
65
|
if (property.value !== "true" && property.value !== "false") {
|
|
61
|
-
this.validationResult.issue(new Language_PropertyValue_Issue(context, propName, property.value, "boolean"))
|
|
66
|
+
this.validationResult.issue(new Language_PropertyValue_Issue(context, propName, property.value, "boolean"))
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
validateInteger = (property: LionWebJsonProperty, propName: string, context: JsonContext): void => {
|
|
66
|
-
const regexp = /^[+-]?(0|[1-9][0-9]*)
|
|
71
|
+
const regexp = /^[+-]?(0|[1-9][0-9]*)$/
|
|
67
72
|
if (!regexp.test(property.value)) {
|
|
68
|
-
this.validationResult.issue(new Language_PropertyValue_Issue(context, propName, property.value, "integer"))
|
|
73
|
+
this.validationResult.issue(new Language_PropertyValue_Issue(context, propName, property.value, "integer"))
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
validateJSON = (property: LionWebJsonProperty, propName: string, context: JsonContext): void => {
|
|
73
78
|
try {
|
|
74
|
-
JSON.parse(property.value)
|
|
79
|
+
JSON.parse(property.value)
|
|
75
80
|
} catch (e) {
|
|
76
|
-
this.validationResult.issue(new Language_PropertyValue_Issue(context, propName, property.value, "JSON"))
|
|
81
|
+
this.validationResult.issue(new Language_PropertyValue_Issue(context, propName, property.value, "JSON"))
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
validateSerializationFormatVersion = (objElement: unknown, context: JsonContext): void => {
|
|
81
86
|
if (typeof objElement !== "string") {
|
|
82
|
-
this.validationResult.issue(new Syntax_SerializationFormatVersion_Issue(context, JSON.stringify(objElement)))
|
|
83
|
-
return
|
|
87
|
+
this.validationResult.issue(new Syntax_SerializationFormatVersion_Issue(context, JSON.stringify(objElement)))
|
|
88
|
+
return
|
|
84
89
|
}
|
|
85
90
|
if (objElement.length === 0) {
|
|
86
|
-
this.validationResult.issue(new Syntax_SerializationFormatVersion_Issue(context, objElement))
|
|
87
|
-
return
|
|
91
|
+
this.validationResult.issue(new Syntax_SerializationFormatVersion_Issue(context, objElement))
|
|
92
|
+
return
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { ValidationIssue } from "../issues/ValidationIssue.js"
|
|
1
|
+
import { ValidationIssue } from "../issues/ValidationIssue.js"
|
|
2
2
|
|
|
3
3
|
export class ValidationResult {
|
|
4
|
-
issues: ValidationIssue[] = []
|
|
4
|
+
issues: ValidationIssue[] = []
|
|
5
5
|
|
|
6
6
|
issue(issue: ValidationIssue) {
|
|
7
|
-
this.issues.push(issue)
|
|
7
|
+
this.issues.push(issue)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
reset() {
|
|
11
|
-
this.issues = []
|
|
11
|
+
this.issues = []
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
hasErrors(): boolean {
|
|
15
|
-
return this.issues.length !== 0
|
|
15
|
+
return this.issues.length !== 0
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
}
|
package/src/validators/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./ValidationResult.js"
|
|
2
|
-
export * from "./SimpleFieldValidator.js"
|
|
3
|
-
export * from "./LionWebSyntaxValidator.js"
|
|
4
|
-
export * from "./LionWebReferenceValidator.js"
|
|
5
|
-
export * from "./LionWebLanguageValidator.js"
|
|
6
|
-
export * from "./LionWebLanguageReferenceValidator.js"
|
|
7
|
-
export * from "./LionWebValidator.js"
|
|
1
|
+
export * from "./ValidationResult.js"
|
|
2
|
+
export * from "./SimpleFieldValidator.js"
|
|
3
|
+
export * from "./LionWebSyntaxValidator.js"
|
|
4
|
+
export * from "./LionWebReferenceValidator.js"
|
|
5
|
+
export * from "./LionWebLanguageValidator.js"
|
|
6
|
+
export * from "./LionWebLanguageReferenceValidator.js"
|
|
7
|
+
export * from "./LionWebValidator.js"
|