@lionweb/validation 0.7.0-beta.9 → 0.7.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.
- package/CHANGELOG.md +6 -1
- package/package.json +37 -37
- package/src/issues/ValidationIssue.ts +4 -4
- package/src/validators/LionWebChunkDefinitions.ts +1 -1
- package/src/validators/LionWebLanguageReferenceValidator.ts +3 -3
- package/src/validators/LionWebLanguageValidator.ts +2 -1
- package/src/validators/ValidationFunctions.ts +4 -10
- package/src/validators/generic/SyntaxValidator.ts +1 -54
- package/src/validators/generic/schema/DefinitionSchema.ts +13 -45
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
- package/dist/issues/LanguageIssues.d.ts +0 -99
- package/dist/issues/LanguageIssues.d.ts.map +0 -1
- package/dist/issues/LanguageIssues.js +0 -146
- package/dist/issues/LanguageIssues.js.map +0 -1
- package/dist/issues/ReferenceIssues.d.ts +0 -43
- package/dist/issues/ReferenceIssues.d.ts.map +0 -1
- package/dist/issues/ReferenceIssues.js +0 -53
- package/dist/issues/ReferenceIssues.js.map +0 -1
- package/dist/issues/SyntaxIssues.d.ts +0 -53
- package/dist/issues/SyntaxIssues.d.ts.map +0 -1
- package/dist/issues/SyntaxIssues.js +0 -81
- package/dist/issues/SyntaxIssues.js.map +0 -1
- package/dist/issues/ValidationIssue.d.ts +0 -15
- package/dist/issues/ValidationIssue.d.ts.map +0 -1
- package/dist/issues/ValidationIssue.js +0 -17
- package/dist/issues/ValidationIssue.js.map +0 -1
- package/dist/issues/index.d.ts +0 -5
- package/dist/issues/index.d.ts.map +0 -1
- package/dist/issues/index.js +0 -5
- package/dist/issues/index.js.map +0 -1
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +0 -24
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +0 -1
- package/dist/languages/CompositeLionWebLanguageWrapper.js +0 -56
- package/dist/languages/CompositeLionWebLanguageWrapper.js.map +0 -1
- package/dist/languages/LanguageRegistry.d.ts +0 -19
- package/dist/languages/LanguageRegistry.d.ts.map +0 -1
- package/dist/languages/LanguageRegistry.js +0 -37
- package/dist/languages/LanguageRegistry.js.map +0 -1
- package/dist/languages/LanguageUtils.d.ts +0 -35
- package/dist/languages/LanguageUtils.d.ts.map +0 -1
- package/dist/languages/LanguageUtils.js +0 -54
- package/dist/languages/LanguageUtils.js.map +0 -1
- package/dist/languages/LionCore-M3.json +0 -2356
- package/dist/languages/LionCore-builtins.json +0 -372
- package/dist/languages/LionWebLanguageWrapper.d.ts +0 -31
- package/dist/languages/LionWebLanguageWrapper.d.ts.map +0 -1
- package/dist/languages/LionWebLanguageWrapper.js +0 -69
- package/dist/languages/LionWebLanguageWrapper.js.map +0 -1
- package/dist/languages/MetaPointerMap.d.ts +0 -11
- package/dist/languages/MetaPointerMap.d.ts.map +0 -1
- package/dist/languages/MetaPointerMap.js +0 -39
- package/dist/languages/MetaPointerMap.js.map +0 -1
- package/dist/languages/index.d.ts +0 -3
- package/dist/languages/index.d.ts.map +0 -1
- package/dist/languages/index.js +0 -3
- package/dist/languages/index.js.map +0 -1
- package/dist/runners/FileUtils.d.ts +0 -6
- package/dist/runners/FileUtils.d.ts.map +0 -1
- package/dist/runners/FileUtils.js +0 -53
- package/dist/runners/FileUtils.js.map +0 -1
- package/dist/runners/RunCheckFolder.d.ts +0 -2
- package/dist/runners/RunCheckFolder.d.ts.map +0 -1
- package/dist/runners/RunCheckFolder.js +0 -6
- package/dist/runners/RunCheckFolder.js.map +0 -1
- package/dist/runners/RunCheckFolderWithLanguage.d.ts +0 -2
- package/dist/runners/RunCheckFolderWithLanguage.d.ts.map +0 -1
- package/dist/runners/RunCheckFolderWithLanguage.js +0 -40
- package/dist/runners/RunCheckFolderWithLanguage.js.map +0 -1
- package/dist/runners/RunCheckOneFile.d.ts +0 -2
- package/dist/runners/RunCheckOneFile.d.ts.map +0 -1
- package/dist/runners/RunCheckOneFile.js +0 -6
- package/dist/runners/RunCheckOneFile.js.map +0 -1
- package/dist/runners/RunCheckOneFileWithLanguage.d.ts +0 -2
- package/dist/runners/RunCheckOneFileWithLanguage.d.ts.map +0 -1
- package/dist/runners/RunCheckOneFileWithLanguage.js +0 -31
- package/dist/runners/RunCheckOneFileWithLanguage.js.map +0 -1
- package/dist/runners/RunLioncoreDiff.d.ts +0 -2
- package/dist/runners/RunLioncoreDiff.d.ts.map +0 -1
- package/dist/runners/RunLioncoreDiff.js +0 -22
- package/dist/runners/RunLioncoreDiff.js.map +0 -1
- package/dist/runners/Utils.d.ts +0 -7
- package/dist/runners/Utils.d.ts.map +0 -1
- package/dist/runners/Utils.js +0 -48
- package/dist/runners/Utils.js.map +0 -1
- package/dist/runners/index.d.ts +0 -3
- package/dist/runners/index.d.ts.map +0 -1
- package/dist/runners/index.js +0 -3
- package/dist/runners/index.js.map +0 -1
- package/dist/validators/LionWebChunkDefinitions.d.ts +0 -9
- package/dist/validators/LionWebChunkDefinitions.d.ts.map +0 -1
- package/dist/validators/LionWebChunkDefinitions.js +0 -100
- package/dist/validators/LionWebChunkDefinitions.js.map +0 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +0 -21
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +0 -1
- package/dist/validators/LionWebLanguageReferenceValidator.js +0 -166
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +0 -1
- package/dist/validators/LionWebLanguageValidator.d.ts +0 -23
- package/dist/validators/LionWebLanguageValidator.d.ts.map +0 -1
- package/dist/validators/LionWebLanguageValidator.js +0 -66
- package/dist/validators/LionWebLanguageValidator.js.map +0 -1
- package/dist/validators/LionWebReferenceValidator.d.ts +0 -43
- package/dist/validators/LionWebReferenceValidator.d.ts.map +0 -1
- package/dist/validators/LionWebReferenceValidator.js +0 -203
- package/dist/validators/LionWebReferenceValidator.js.map +0 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts +0 -9
- package/dist/validators/LionWebSyntaxValidator.d.ts.map +0 -1
- package/dist/validators/LionWebSyntaxValidator.js +0 -11
- package/dist/validators/LionWebSyntaxValidator.js.map +0 -1
- package/dist/validators/LionWebValidator.d.ts +0 -24
- package/dist/validators/LionWebValidator.d.ts.map +0 -1
- package/dist/validators/LionWebValidator.js +0 -55
- package/dist/validators/LionWebValidator.js.map +0 -1
- package/dist/validators/ValidationFunctions.d.ts +0 -60
- package/dist/validators/ValidationFunctions.d.ts.map +0 -1
- package/dist/validators/ValidationFunctions.js +0 -110
- package/dist/validators/ValidationFunctions.js.map +0 -1
- package/dist/validators/generic/SyntaxValidator.d.ts +0 -51
- package/dist/validators/generic/SyntaxValidator.d.ts.map +0 -1
- package/dist/validators/generic/SyntaxValidator.js +0 -201
- package/dist/validators/generic/SyntaxValidator.js.map +0 -1
- package/dist/validators/generic/ValidationResult.d.ts +0 -8
- package/dist/validators/generic/ValidationResult.d.ts.map +0 -1
- package/dist/validators/generic/ValidationResult.js +0 -15
- package/dist/validators/generic/ValidationResult.js.map +0 -1
- package/dist/validators/generic/index.d.ts +0 -4
- package/dist/validators/generic/index.d.ts.map +0 -1
- package/dist/validators/generic/index.js +0 -4
- package/dist/validators/generic/index.js.map +0 -1
- package/dist/validators/generic/schema/DefinitionSchema.d.ts +0 -26
- package/dist/validators/generic/schema/DefinitionSchema.d.ts.map +0 -1
- package/dist/validators/generic/schema/DefinitionSchema.js +0 -75
- package/dist/validators/generic/schema/DefinitionSchema.js.map +0 -1
- package/dist/validators/generic/schema/ValidationTypes.d.ts +0 -101
- package/dist/validators/generic/schema/ValidationTypes.d.ts.map +0 -1
- package/dist/validators/generic/schema/ValidationTypes.js +0 -43
- package/dist/validators/generic/schema/ValidationTypes.js.map +0 -1
- package/dist/validators/generic/schema/index.d.ts +0 -3
- package/dist/validators/generic/schema/index.d.ts.map +0 -1
- package/dist/validators/generic/schema/index.js +0 -3
- package/dist/validators/generic/schema/index.js.map +0 -1
- package/dist/validators/index.d.ts +0 -9
- package/dist/validators/index.d.ts.map +0 -1
- package/dist/validators/index.js +0 -9
- package/dist/validators/index.js.map +0 -1
- package/tsconfig.json +0 -8
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { isEqualMetaPointer } from "@lionweb/json";
|
|
2
|
-
import { isLionWebM3Language, JsonContext, LionWebJsonChunkWrapper, MetaPointers } from "@lionweb/json-utils";
|
|
3
|
-
import { GenericIssue } from "../issues/index.js";
|
|
4
|
-
import { MissingM3Language_Issue } from "../issues/LanguageIssues.js";
|
|
5
|
-
import { isConcept } from "../languages/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Validates whether a chunk is a valid language definition
|
|
8
|
-
*/
|
|
9
|
-
export class LionWebLanguageValidator {
|
|
10
|
-
// availableLanguages: LionWebLanguageDefinition[] = []
|
|
11
|
-
constructor(validationResult, registry) {
|
|
12
|
-
this.registry = registry;
|
|
13
|
-
this.validationResult = validationResult;
|
|
14
|
-
this.chunkWrapper = undefined;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Check whether the metamodel is a Language.
|
|
18
|
-
* Assumption is that _chunk_ is already validated as a correct :LionWebJsonChunk
|
|
19
|
-
* @param chunk
|
|
20
|
-
*/
|
|
21
|
-
validateLanguage(chunk) {
|
|
22
|
-
this.chunkWrapper = new LionWebJsonChunkWrapper(chunk);
|
|
23
|
-
const usedM3Language = chunk.languages.find(lang => isLionWebM3Language(lang));
|
|
24
|
-
if (usedM3Language === undefined) {
|
|
25
|
-
this.validationResult.issue(new MissingM3Language_Issue(new JsonContext(null, ["languages"])));
|
|
26
|
-
}
|
|
27
|
-
const languageNodes = this.chunkWrapper.findNodesOfClassifier(MetaPointers.Language);
|
|
28
|
-
if (languageNodes.length !== 1) {
|
|
29
|
-
// TODO Better error handling.
|
|
30
|
-
console.error("Error: xpected exactly one Language node, found " + languageNodes.length + " => " + JSON.stringify(languageNodes));
|
|
31
|
-
}
|
|
32
|
-
chunk.nodes.forEach((node, index) => {
|
|
33
|
-
if (!isConcept(node)) {
|
|
34
|
-
this.validationResult.issue(new GenericIssue(new JsonContext(null, ["nodes", index]), `node ${node.id} is not a concept`));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.validateConcept(node);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
validateConcept(node) {
|
|
42
|
-
node.properties.forEach(prop => {
|
|
43
|
-
const properties = this.chunkWrapper?.findNodesOfClassifier(MetaPointers.Property);
|
|
44
|
-
const matchedProperty = properties?.find(p => isEqualMetaPointer(p.classifier, prop.property));
|
|
45
|
-
// DUMMY
|
|
46
|
-
return matchedProperty !== undefined;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
validateNode(node) {
|
|
50
|
-
const classifier = this.registry.getNodeByMetaPointer(node.classifier);
|
|
51
|
-
if (classifier === undefined) {
|
|
52
|
-
this.validationResult.issue(new GenericIssue(new JsonContext(null, ["nodes"]), `Classifier ${node.classifier.key} not found for node ${node.id}`));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.validateProperties(node, classifier);
|
|
56
|
-
}
|
|
57
|
-
validateProperties(node, classifier) {
|
|
58
|
-
node.properties.forEach(actualProp => {
|
|
59
|
-
const propClassifier = this.registry.getNodeByMetaPointer(actualProp.property);
|
|
60
|
-
if (propClassifier === undefined) {
|
|
61
|
-
this.validationResult.issue(new GenericIssue(new JsonContext(null, ["nodes", "properties"]), `Property ${actualProp.property.key} not found for classifier ${classifier.id}`));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=LionWebLanguageValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebLanguageValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebLanguageValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqC,MAAM,eAAe,CAAA;AACrF,OAAO,EAAE,mBAAmB,EAAE,WAA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,CAAC,CAAA;IAC7C,CAAC;IAED,kBAAkB,CAAC,IAAqB,EAAE,UAA2B;QACjE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YACjC,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;YAC9E,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,gBAAgB,CAAC,KAAK,CACvB,IAAI,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,EAC3D,YAAY,UAAU,CAAC,QAAQ,CAAC,GAAG,6BAA6B,UAAU,CAAC,EAAE,EAAE,CAAC,CACvF,CAAA;YACL,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { LionWebJsonChunk, LionWebJsonMetaPointer, LionWebJsonNode, LionWebJsonUsedLanguage } from "@lionweb/json";
|
|
2
|
-
import { JsonContext, LionWebJsonChunkWrapper } from "@lionweb/json-utils";
|
|
3
|
-
import { ValidationResult } from "./generic/ValidationResult.js";
|
|
4
|
-
/**
|
|
5
|
-
* Assuming that the syntax is correct, check whether all LionWeb references are correct,
|
|
6
|
-
* as far as they do not need the used language definition.
|
|
7
|
-
*/
|
|
8
|
-
export declare class LionWebReferenceValidator {
|
|
9
|
-
validationResult: ValidationResult;
|
|
10
|
-
nodesIdMap: Map<string, LionWebJsonNode>;
|
|
11
|
-
constructor(validationResult: ValidationResult);
|
|
12
|
-
validateNodeIds(obj: LionWebJsonChunk, ctx: JsonContext): void;
|
|
13
|
-
validate(obj: LionWebJsonChunkWrapper): void;
|
|
14
|
-
/**
|
|
15
|
-
* Check whether the metapointer refers to a language defined in the usedLanguages of chunk.
|
|
16
|
-
* @param chunk
|
|
17
|
-
* @param metaPointer
|
|
18
|
-
* @param context
|
|
19
|
-
*/
|
|
20
|
-
validateLanguageReference(chunk: LionWebJsonChunkWrapper, metaPointer: LionWebJsonMetaPointer, context: JsonContext): void;
|
|
21
|
-
/**
|
|
22
|
-
* Check whether there are duplicate values in `strings`.
|
|
23
|
-
* @param strings
|
|
24
|
-
* @param context
|
|
25
|
-
*/
|
|
26
|
-
checkDuplicate(strings: string[], context: JsonContext): void;
|
|
27
|
-
/**
|
|
28
|
-
* Checks whether there are duplicate usedLanguages in `usedLanguages`.
|
|
29
|
-
* usedLanguages are considered equal when bith their `key` and `version` are identical.
|
|
30
|
-
* @param usedLanguages
|
|
31
|
-
* @param context
|
|
32
|
-
*/
|
|
33
|
-
checkDuplicateUsedLanguage(usedLanguages: LionWebJsonUsedLanguage[], context: JsonContext): void;
|
|
34
|
-
/**
|
|
35
|
-
* Checks whether the parent of node recursively points to `node` itself.
|
|
36
|
-
* @param node The noide being checked
|
|
37
|
-
* @param context The location in the JSON
|
|
38
|
-
*/
|
|
39
|
-
checkParentCircular(node: LionWebJsonNode, context: JsonContext): void;
|
|
40
|
-
validateExistsAsChild(context: JsonContext, parent: LionWebJsonNode | undefined, child: LionWebJsonNode): void;
|
|
41
|
-
validateChildrenHaveCorrectParent(node: LionWebJsonNode, context: JsonContext): void;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=LionWebReferenceValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebReferenceValidator.d.ts","sourceRoot":"","sources":["../../src/validators/LionWebReferenceValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAA0B,sBAAsB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACrJ,OAAO,EAAc,WAAW,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAStF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAEhE;;;GAGG;AACH,qBAAa,yBAAyB;IAClC,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAqC;gBAEjE,gBAAgB,EAAE,gBAAgB;IAI9C,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;IAW9D,QAAQ,CAAC,GAAG,EAAE,uBAAuB,GAAG,IAAI;IAqD5C;;;;;OAKG;IACH,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW;IAWnH;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW;IActD;;;;;OAKG;IACH,0BAA0B,CAAC,aAAa,EAAE,uBAAuB,EAAE,EAAE,OAAO,EAAE,WAAW;IAiBzF;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW;IAsB/D,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe;IAevG,iCAAiC,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW;CAmChF"}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { ChunkUtils, JsonContext } from "@lionweb/json-utils";
|
|
2
|
-
import { Duplicates_Issue, Reference_ChildMissingInParent_Issue, Reference_CirculairParent_Issue, Reference_DuplicateNodeId_Issue, Reference_LanguageUnknown_Issue, Reference_ParentMissingInChild_Issue } from "../issues/ReferenceIssues.js";
|
|
3
|
-
/**
|
|
4
|
-
* Assuming that the syntax is correct, check whether all LionWeb references are correct,
|
|
5
|
-
* as far as they do not need the used language definition.
|
|
6
|
-
*/
|
|
7
|
-
export class LionWebReferenceValidator {
|
|
8
|
-
constructor(validationResult) {
|
|
9
|
-
this.nodesIdMap = new Map();
|
|
10
|
-
this.validationResult = validationResult;
|
|
11
|
-
}
|
|
12
|
-
validateNodeIds(obj, ctx) {
|
|
13
|
-
// put all nodes in a map, validate that there are no two nodes with the same id.
|
|
14
|
-
obj.nodes.forEach((node, index) => {
|
|
15
|
-
// this.validationResult.check(this.nodesIdMap.get(node.id) === undefined, `Node number ${index} has duplicate id "${node.id}"`);
|
|
16
|
-
if (!(this.nodesIdMap.get(node.id) === undefined)) {
|
|
17
|
-
this.validationResult.issue(new Reference_DuplicateNodeId_Issue(ctx.concat("nodes", index), node.id));
|
|
18
|
-
}
|
|
19
|
-
this.nodesIdMap.set(node.id, node);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
validate(obj) {
|
|
23
|
-
const rootCtx = new JsonContext(null, ["$"]);
|
|
24
|
-
this.checkDuplicateUsedLanguage(obj.jsonChunk.languages, rootCtx);
|
|
25
|
-
this.validateNodeIds(obj.jsonChunk, rootCtx);
|
|
26
|
-
obj.jsonChunk.nodes.forEach((node, nodeIndex) => {
|
|
27
|
-
const context = rootCtx.concat(`node`, nodeIndex);
|
|
28
|
-
const parentNode = node.parent;
|
|
29
|
-
if (parentNode !== null) {
|
|
30
|
-
this.validateExistsAsChild(context, this.nodesIdMap.get(parentNode), node);
|
|
31
|
-
}
|
|
32
|
-
this.validateLanguageReference(obj, node.classifier, context);
|
|
33
|
-
this.checkParentCircular(node, context);
|
|
34
|
-
this.checkDuplicate(node.annotations, rootCtx.concat("node", nodeIndex, "annotations"));
|
|
35
|
-
this.validateChildrenHaveCorrectParent(node, rootCtx.concat("node", nodeIndex));
|
|
36
|
-
node.properties.forEach((prop, propertyIndex) => {
|
|
37
|
-
this.validateLanguageReference(obj, prop.property, rootCtx.concat("node", nodeIndex, "property", propertyIndex));
|
|
38
|
-
});
|
|
39
|
-
node.containments.forEach((containment, childIndex) => {
|
|
40
|
-
this.validateLanguageReference(obj, containment.containment, rootCtx.concat("node", nodeIndex, "containments", childIndex));
|
|
41
|
-
this.checkDuplicate(containment.children, rootCtx.concat("node", nodeIndex, "containments", childIndex));
|
|
42
|
-
containment.children.forEach(childId => {
|
|
43
|
-
const childNode = this.nodesIdMap.get(childId);
|
|
44
|
-
if (childNode !== undefined) {
|
|
45
|
-
if (childNode.parent !== null && childNode.parent !== undefined && childNode.parent !== node.id) {
|
|
46
|
-
this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context, node, childNode));
|
|
47
|
-
// TODO this.validationResult.error(`Child "${childId}" with parent "${childNode.parent}" is defined as child in node "${node.id}"`);
|
|
48
|
-
}
|
|
49
|
-
if (childNode.parent === null || childNode.parent === undefined) {
|
|
50
|
-
// TODO this.validationResult.error(`Child "${childId}" of node "${node.id}" has different parent "${childNode.parent}"`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
node.annotations.forEach(annotationId => {
|
|
56
|
-
const annotation = this.nodesIdMap.get(annotationId);
|
|
57
|
-
if (annotation !== undefined) {
|
|
58
|
-
if (annotation.parent !== null && annotation.parent !== undefined && annotation.parent !== node.id) {
|
|
59
|
-
this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context, node, annotation));
|
|
60
|
-
// TODO this.validationResult.error(`Child "${annotationId}" with parent "${childNode.parent}" is defined as child in node "${node.id}"`);
|
|
61
|
-
}
|
|
62
|
-
if (annotation.parent === null || annotation.parent === undefined) {
|
|
63
|
-
// TODO this.validationResult.error(`Child "${annotationId}" of node "${node.id}" has different parent "${childNode.parent}"`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
node.references.forEach((ref, refIndex) => {
|
|
68
|
-
this.validateLanguageReference(obj, ref.reference, rootCtx.concat("node", nodeIndex, "references", refIndex));
|
|
69
|
-
// TODO Check for duplicate targets?
|
|
70
|
-
// If so, what to check because there can be either or both a `resolveInfo` and a `reference`
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Check whether the metapointer refers to a language defined in the usedLanguages of chunk.
|
|
76
|
-
* @param chunk
|
|
77
|
-
* @param metaPointer
|
|
78
|
-
* @param context
|
|
79
|
-
*/
|
|
80
|
-
validateLanguageReference(chunk, metaPointer, context) {
|
|
81
|
-
const lang = ChunkUtils.findLwUsedLanguageWithVersion(chunk.jsonChunk, metaPointer.language, metaPointer.version);
|
|
82
|
-
if (lang === undefined || lang === null) {
|
|
83
|
-
this.validationResult.issue(new Reference_LanguageUnknown_Issue(context, metaPointer));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
if (lang.version !== metaPointer.version) {
|
|
87
|
-
this.validationResult.issue(new Reference_LanguageUnknown_Issue(context, metaPointer));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Check whether there are duplicate values in `strings`.
|
|
93
|
-
* @param strings
|
|
94
|
-
* @param context
|
|
95
|
-
*/
|
|
96
|
-
checkDuplicate(strings, context) {
|
|
97
|
-
if (strings === null || strings === undefined) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const alreadySeen = {};
|
|
101
|
-
strings.forEach(str => {
|
|
102
|
-
if (alreadySeen[str]) {
|
|
103
|
-
this.validationResult.issue(new Duplicates_Issue(context, str));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
alreadySeen[str] = true;
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Checks whether there are duplicate usedLanguages in `usedLanguages`.
|
|
112
|
-
* usedLanguages are considered equal when bith their `key` and `version` are identical.
|
|
113
|
-
* @param usedLanguages
|
|
114
|
-
* @param context
|
|
115
|
-
*/
|
|
116
|
-
checkDuplicateUsedLanguage(usedLanguages, context) {
|
|
117
|
-
if (usedLanguages === null || usedLanguages === undefined) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const alreadySeen = new Map();
|
|
121
|
-
usedLanguages.forEach((usedLanguage, index) => {
|
|
122
|
-
const seenKeys = alreadySeen.get(usedLanguage.key);
|
|
123
|
-
if (seenKeys !== null && seenKeys !== undefined) {
|
|
124
|
-
if (seenKeys.includes(usedLanguage.version)) {
|
|
125
|
-
this.validationResult.issue(new Duplicates_Issue(context.concat("language", index, "version"), usedLanguage.version));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
alreadySeen.set(usedLanguage.key, [usedLanguage.version]);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Checks whether the parent of node recursively points to `node` itself.
|
|
135
|
-
* @param node The noide being checked
|
|
136
|
-
* @param context The location in the JSON
|
|
137
|
-
*/
|
|
138
|
-
checkParentCircular(node, context) {
|
|
139
|
-
if (node === null || node === undefined) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (node.parent === null || node.parent === undefined) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
let current = node;
|
|
146
|
-
const seenParents = [node.id];
|
|
147
|
-
while (current !== null && current !== undefined && current.parent !== null && current.parent !== undefined) {
|
|
148
|
-
const nextParent = current.parent;
|
|
149
|
-
if (nextParent !== null && nextParent !== undefined && seenParents.includes(nextParent)) {
|
|
150
|
-
this.validationResult.issue(new Reference_CirculairParent_Issue(context.concat("???"), this.nodesIdMap.get(nextParent), seenParents));
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
seenParents.push(nextParent);
|
|
154
|
-
current = this.nodesIdMap.get(nextParent);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
validateExistsAsChild(context, parent, child) {
|
|
158
|
-
if (parent === undefined || parent === null) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
for (const containment of parent.containments) {
|
|
162
|
-
if (containment.children.includes(child.id)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (parent.annotations.includes(child.id)) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, child, parent));
|
|
170
|
-
}
|
|
171
|
-
validateChildrenHaveCorrectParent(node, context) {
|
|
172
|
-
node.containments.forEach((child) => {
|
|
173
|
-
child.children.forEach((childId, index) => {
|
|
174
|
-
const childNode = this.nodesIdMap.get(childId);
|
|
175
|
-
if (childNode !== undefined) {
|
|
176
|
-
if (childNode.parent !== node.id) {
|
|
177
|
-
// TODO Check that this is already tested from the child in vaidateExistsAsChild().
|
|
178
|
-
}
|
|
179
|
-
if (childNode.parent === null || childNode.parent === undefined) {
|
|
180
|
-
this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context.concat("child", "containment", "key", index), node, childNode));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
node.annotations.forEach((annotationId, annotationIndex) => {
|
|
186
|
-
const childNode = this.nodesIdMap.get(annotationId);
|
|
187
|
-
if (childNode !== undefined) {
|
|
188
|
-
if (childNode.parent === null || childNode.parent === undefined) {
|
|
189
|
-
this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context.concat("annotations", annotationIndex), node, childNode));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
// for (const childId of NodeUtils.allChildren(node)) {
|
|
194
|
-
// const childNode = this.nodesIdMap.get(childId);
|
|
195
|
-
// if (childNode !== undefined) {
|
|
196
|
-
// if (childNode.parent !== node.id) {
|
|
197
|
-
// this.validationResult.error(`QQ Parent of child "${childId}" is "${childNode.parent}", but should be "${node.id}" in ${context}`);
|
|
198
|
-
// }
|
|
199
|
-
// }
|
|
200
|
-
// }
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
//# sourceMappingURL=LionWebReferenceValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebReferenceValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebReferenceValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,U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,SAAS,CAAC,MAAM,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC9D,IAAI,CAAC,gBAAgB,CAAC,KAAK,CACvB,IAAI,oCAAoC,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAC5G,CAAA;gBACL,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAA;QACF,uDAAuD;QACvD,sDAAsD;QACtD,qCAAqC;QACrC,8CAA8C;QAC9C,iJAAiJ;QACjJ,YAAY;QACZ,QAAQ;QACR,IAAI;IACR,CAAC;CACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SyntaxValidator } from "./generic/SyntaxValidator.js";
|
|
2
|
-
import { ValidationResult } from "./generic/ValidationResult.js";
|
|
3
|
-
/**
|
|
4
|
-
* LionWebSyntaxValidator can check whether objects are structurally LionWeb objects.
|
|
5
|
-
*/
|
|
6
|
-
export declare class LionWebSyntaxValidator extends SyntaxValidator {
|
|
7
|
-
constructor(validationResult: ValidationResult);
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=LionWebSyntaxValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebSyntaxValidator.d.ts","sourceRoot":"","sources":["../../src/validators/LionWebSyntaxValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAGhE;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;gBAE3C,gBAAgB,EAAE,gBAAgB;CAGjD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SyntaxValidator } from "./generic/SyntaxValidator.js";
|
|
2
|
-
import { LionWebSchema } from "./LionWebChunkDefinitions.js";
|
|
3
|
-
/**
|
|
4
|
-
* LionWebSyntaxValidator can check whether objects are structurally LionWeb objects.
|
|
5
|
-
*/
|
|
6
|
-
export class LionWebSyntaxValidator extends SyntaxValidator {
|
|
7
|
-
constructor(validationResult) {
|
|
8
|
-
super(validationResult, LionWebSchema);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=LionWebSyntaxValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebSyntaxValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebSyntaxValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IAEvD,YAAY,gBAAkC;QAC1C,KAAK,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IAC1C,CAAC;CACJ"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { LanguageRegistry } from "../languages/index.js";
|
|
2
|
-
import { ValidationResult } from "./generic/ValidationResult.js";
|
|
3
|
-
import { LionWebReferenceValidator } from "./LionWebReferenceValidator.js";
|
|
4
|
-
import { LionWebSyntaxValidator } from "./LionWebSyntaxValidator.js";
|
|
5
|
-
/**
|
|
6
|
-
* Combined validator that calls all available validators.
|
|
7
|
-
* Will stop when one validator fails.
|
|
8
|
-
*/
|
|
9
|
-
export declare class LionWebValidator {
|
|
10
|
-
private registry;
|
|
11
|
-
object: unknown;
|
|
12
|
-
chunk: unknown;
|
|
13
|
-
validationResult: ValidationResult;
|
|
14
|
-
syntaxValidator: LionWebSyntaxValidator;
|
|
15
|
-
referenceValidator: LionWebReferenceValidator;
|
|
16
|
-
syntaxCorrect: boolean;
|
|
17
|
-
referencesCorrect: boolean;
|
|
18
|
-
constructor(json: unknown, registry: LanguageRegistry);
|
|
19
|
-
validateAll(): void;
|
|
20
|
-
validateSyntax(): void;
|
|
21
|
-
validateReferences(): void;
|
|
22
|
-
validateForLanguage(): void;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=LionWebValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebValidator.d.ts","sourceRoot":"","sources":["../../src/validators/LionWebValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE;;;GAGG;AACH,qBAAa,gBAAgB;IAUE,OAAO,CAAC,QAAQ;IAT3C,MAAM,EAAE,OAAO,CAAA;IAEf,KAAK,EAAE,OAAO,CAAA;IACd,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,eAAe,EAAE,sBAAsB,CAAA;IACvC,kBAAkB,EAAE,yBAAyB,CAAA;IAC7C,aAAa,EAAE,OAAO,CAAQ;IAC9B,iBAAiB,EAAE,OAAO,CAAQ;gBAEtB,IAAI,EAAE,OAAO,EAAU,QAAQ,EAAE,gBAAgB;IAO7D,WAAW;IAMX,cAAc;IAQd,kBAAkB,IAAI,IAAI;IAU1B,mBAAmB,IAAI,IAAI;CAiB9B"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { LionWebJsonChunkWrapper } from "@lionweb/json-utils";
|
|
2
|
-
import { ValidationResult } from "./generic/ValidationResult.js";
|
|
3
|
-
import { LionWebLanguageReferenceValidator } from "./LionWebLanguageReferenceValidator.js";
|
|
4
|
-
import { LionWebReferenceValidator } from "./LionWebReferenceValidator.js";
|
|
5
|
-
import { LionWebSyntaxValidator } from "./LionWebSyntaxValidator.js";
|
|
6
|
-
/**
|
|
7
|
-
* Combined validator that calls all available validators.
|
|
8
|
-
* Will stop when one validator fails.
|
|
9
|
-
*/
|
|
10
|
-
export class LionWebValidator {
|
|
11
|
-
constructor(json, registry) {
|
|
12
|
-
this.registry = registry;
|
|
13
|
-
this.syntaxCorrect = false;
|
|
14
|
-
this.referencesCorrect = false;
|
|
15
|
-
this.object = json;
|
|
16
|
-
this.validationResult = new ValidationResult();
|
|
17
|
-
this.syntaxValidator = new LionWebSyntaxValidator(this.validationResult);
|
|
18
|
-
this.referenceValidator = new LionWebReferenceValidator(this.validationResult);
|
|
19
|
-
}
|
|
20
|
-
validateAll() {
|
|
21
|
-
this.validateSyntax();
|
|
22
|
-
this.validateReferences();
|
|
23
|
-
this.validateForLanguage();
|
|
24
|
-
}
|
|
25
|
-
validateSyntax() {
|
|
26
|
-
this.syntaxValidator.validate(this.object, "LionWebJsonChunk");
|
|
27
|
-
this.syntaxCorrect = !this.validationResult.hasErrors();
|
|
28
|
-
if (this.syntaxCorrect) {
|
|
29
|
-
this.chunk = new LionWebJsonChunkWrapper(this.object);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
validateReferences() {
|
|
33
|
-
if (!this.syntaxCorrect) {
|
|
34
|
-
// console.log("validateReferences not executed because there are syntax errors.")
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// when syntax is correct we know the chunk is actually a chunk!
|
|
38
|
-
this.referenceValidator.validate(this.chunk);
|
|
39
|
-
this.referencesCorrect = !this.validationResult.hasErrors();
|
|
40
|
-
}
|
|
41
|
-
validateForLanguage() {
|
|
42
|
-
if (!this.syntaxCorrect) {
|
|
43
|
-
// console.log("validateForLanguage not executed because there are syntax errors.")
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (!this.referencesCorrect) {
|
|
47
|
-
// console.log("validateForLanguage not executed because there are reference errors.")
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const languageReferenceValidator = new LionWebLanguageReferenceValidator(this.validationResult, this.registry);
|
|
51
|
-
// when syntax is correct we know the chunk is actually a chunk!
|
|
52
|
-
languageReferenceValidator.validate(this.chunk);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=LionWebValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionWebValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAA;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAUzB,YAAY,IAAa,EAAU,QAA0B;QAA1B,aAAQ,GAAR,QAAQ,CAAkB;QAH7D,kBAAa,GAAY,KAAK,CAAA;QAC9B,sBAAiB,GAAY,KAAK,CAAA;QAG9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAA;QAC9C,IAAI,CAAC,eAAe,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACxE,IAAI,CAAC,kBAAkB,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;IAClF,CAAC;IAED,WAAW;QACP,IAAI,CAAC,cAAc,EAAE,CAAA;QACrB,IAAI,CAAC,kBAAkB,EAAE,CAAA;QACzB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC9B,CAAC;IAED,cAAc;QACV,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;QAC9D,IAAI,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAA;QACvD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAA0B,CAAC,CAAA;QAC7E,CAAC;IACL,CAAC;IAED,kBAAkB;QACd,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACtB,kFAAkF;YAClF,OAAM;QACV,CAAC;QACD,gEAAgE;QAChE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAA;QACvE,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAA;IAC/D,CAAC;IAED,mBAAmB;QACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACtB,mFAAmF;YACnF,OAAM;QACV,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC1B,sFAAsF;YACtF,OAAM;QACV,CAAC;QACD,MAAM,0BAA0B,GAAG,IAAI,iCAAiC,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9G,gEAAgE;QAChE,0BAA0B,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAA;IAC9E,CAAC;CAKJ"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A list of functions that are used to validate primitive fields for LionWeb conformance.
|
|
3
|
-
* Used in the LionWebSyntaxValidator.
|
|
4
|
-
*/
|
|
5
|
-
import { JsonContext } from "@lionweb/json-utils";
|
|
6
|
-
import { ValidationResult } from "./generic/ValidationResult.js";
|
|
7
|
-
import { PropertyDefinition } from "./generic/schema/ValidationTypes.js";
|
|
8
|
-
/**
|
|
9
|
-
* Check whether `id` is a valid LionWeb id.
|
|
10
|
-
* @param value The `value` to be checked.
|
|
11
|
-
* @param result Any validation issues found will be put into this object.
|
|
12
|
-
* @param context The context for the error message in errors.
|
|
13
|
-
*/
|
|
14
|
-
export declare function validateId<String>(value: String, result: ValidationResult, context: JsonContext): void;
|
|
15
|
-
/**
|
|
16
|
-
* Check whether `key` is a valid LionWeb key.
|
|
17
|
-
* @param value The `key` to be checked.
|
|
18
|
-
* @param result Any validation issues found will be put into this object.
|
|
19
|
-
* @param context The context for the error message in errors.
|
|
20
|
-
*/
|
|
21
|
-
export declare function validateKey<String>(value: String, result: ValidationResult, context: JsonContext): void;
|
|
22
|
-
/**
|
|
23
|
-
* Check whether `version` is a valid LionWeb version.
|
|
24
|
-
* @param value The version to be checked
|
|
25
|
-
* @param result Any validation issues found will be put into this object.
|
|
26
|
-
* @param context The location in the overall JSON.
|
|
27
|
-
*/
|
|
28
|
-
export declare function validateVersion<String>(value: String, result: ValidationResult, context: JsonContext): void;
|
|
29
|
-
/**
|
|
30
|
-
* Check whether the string `value` represents a LionWeb boolean, its value should be "true" or "false".
|
|
31
|
-
* @param value The value to be checked
|
|
32
|
-
* @param result Any validation issues found will be put into this object.
|
|
33
|
-
* @param context The location in the overall JSON.
|
|
34
|
-
* @param propDef The PropertyDefinition for this value
|
|
35
|
-
*/
|
|
36
|
-
export declare function validateBoolean<String>(value: String, result: ValidationResult, context: JsonContext, propDef?: PropertyDefinition): void;
|
|
37
|
-
/**
|
|
38
|
-
* Check whether the string `value` represents a LionWeb integer
|
|
39
|
-
* @param value The value to be checked
|
|
40
|
-
* @param result Any validation issues found will be put into this object.
|
|
41
|
-
* @param context The location in the overall JSON.
|
|
42
|
-
* @param propDef The PropertyDefinition for this value
|
|
43
|
-
*/
|
|
44
|
-
export declare function validateInteger<String>(value: String, result: ValidationResult, context: JsonContext, propDef?: PropertyDefinition): void;
|
|
45
|
-
/**
|
|
46
|
-
* Check whether the string `value` represents a LionWeb Json.
|
|
47
|
-
* @param value The value to be checked
|
|
48
|
-
* @param result Any validation issues found will be put into this object.
|
|
49
|
-
* @param context The location in the overall JSON.
|
|
50
|
-
* @param propDef The PropertyDefinition for this value
|
|
51
|
-
*/
|
|
52
|
-
export declare function validateJSON<String>(value: String, result: ValidationResult, context: JsonContext, propDef?: PropertyDefinition): void;
|
|
53
|
-
/**
|
|
54
|
-
* Check whether the string `value` is a correct LionWeb serializationFormatVersion.
|
|
55
|
-
* @param value
|
|
56
|
-
* @param result
|
|
57
|
-
* @param context
|
|
58
|
-
*/
|
|
59
|
-
export declare function validateSerializationFormatVersion<String>(value: String, result: ValidationResult, context: JsonContext): void;
|
|
60
|
-
//# sourceMappingURL=ValidationFunctions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationFunctions.d.ts","sourceRoot":"","sources":["../../src/validators/ValidationFunctions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AASjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAExE;;;;;GAKG;AAEH,wBAAgB,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAMtG;AAED;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAMvG;AAED;;;;;GAKG;AAEH,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAK3G;AAED;;;;;;GAMG;AAEH,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAYzI;AAED;;;;;;GAMG;AAEH,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAMzI;AAED;;;;;;GAMG;AAEH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAUtI;AAED;;;;;GAKG;AAEH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAS9H"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Language_PropertyValue_Issue } from "../issues/LanguageIssues.js";
|
|
2
|
-
import { Syntax_IdFormat_Issue, Syntax_KeyFormat_Issue, Syntax_PropertyNullIssue, Syntax_SerializationFormatVersion_Issue, Syntax_VersionFormat_Issue } from "../issues/SyntaxIssues.js";
|
|
3
|
-
/**
|
|
4
|
-
* Check whether `id` is a valid LionWeb id.
|
|
5
|
-
* @param value The `value` to be checked.
|
|
6
|
-
* @param result Any validation issues found will be put into this object.
|
|
7
|
-
* @param context The context for the error message in errors.
|
|
8
|
-
*/
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
10
|
-
export function validateId(value, result, context) {
|
|
11
|
-
const idString = "" + value;
|
|
12
|
-
const regexp = /^[a-zA-Z0-9_-][a-zA-Z0-9_-]*$/;
|
|
13
|
-
if (!regexp.test(idString)) {
|
|
14
|
-
result.issue(new Syntax_IdFormat_Issue(context, idString));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Check whether `key` is a valid LionWeb key.
|
|
19
|
-
* @param value The `key` to be checked.
|
|
20
|
-
* @param result Any validation issues found will be put into this object.
|
|
21
|
-
* @param context The context for the error message in errors.
|
|
22
|
-
*/
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
24
|
-
export function validateKey(value, result, context) {
|
|
25
|
-
const keyString = "" + value;
|
|
26
|
-
const regexp = /^[a-zA-Z0-9_-][a-zA-Z0-9_-]*$/;
|
|
27
|
-
if (!regexp.test(keyString)) {
|
|
28
|
-
result.issue(new Syntax_KeyFormat_Issue(context, keyString));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Check whether `version` is a valid LionWeb version.
|
|
33
|
-
* @param value The version to be checked
|
|
34
|
-
* @param result Any validation issues found will be put into this object.
|
|
35
|
-
* @param context The location in the overall JSON.
|
|
36
|
-
*/
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
38
|
-
export function validateVersion(value, result, context) {
|
|
39
|
-
const versionString = "" + value;
|
|
40
|
-
if (versionString.length === 0) {
|
|
41
|
-
result.issue(new Syntax_VersionFormat_Issue(context, versionString));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Check whether the string `value` represents a LionWeb boolean, its value should be "true" or "false".
|
|
46
|
-
* @param value The value to be checked
|
|
47
|
-
* @param result Any validation issues found will be put into this object.
|
|
48
|
-
* @param context The location in the overall JSON.
|
|
49
|
-
* @param propDef The PropertyDefinition for this value
|
|
50
|
-
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
52
|
-
export function validateBoolean(value, result, context, propDef) {
|
|
53
|
-
const valueAsPrimitive = "" + value;
|
|
54
|
-
if (valueAsPrimitive !== "true" && valueAsPrimitive !== "false") {
|
|
55
|
-
result.issue(new Language_PropertyValue_Issue(context, propDef ? propDef.name : "unknown", valueAsPrimitive, "boolean " + JSON.stringify(value)));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Check whether the string `value` represents a LionWeb integer
|
|
60
|
-
* @param value The value to be checked
|
|
61
|
-
* @param result Any validation issues found will be put into this object.
|
|
62
|
-
* @param context The location in the overall JSON.
|
|
63
|
-
* @param propDef The PropertyDefinition for this value
|
|
64
|
-
*/
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
66
|
-
export function validateInteger(value, result, context, propDef) {
|
|
67
|
-
const valueAsPrimitive = "" + value;
|
|
68
|
-
const regexp = /^[+-]?(0|[1-9][0-9]*)$/;
|
|
69
|
-
if (valueAsPrimitive === null || !regexp.test(valueAsPrimitive)) {
|
|
70
|
-
result.issue(new Language_PropertyValue_Issue(context, propDef ? propDef.name : "unknown", valueAsPrimitive, "integer"));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Check whether the string `value` represents a LionWeb Json.
|
|
75
|
-
* @param value The value to be checked
|
|
76
|
-
* @param result Any validation issues found will be put into this object.
|
|
77
|
-
* @param context The location in the overall JSON.
|
|
78
|
-
* @param propDef The PropertyDefinition for this value
|
|
79
|
-
*/
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
81
|
-
export function validateJSON(value, result, context, propDef) {
|
|
82
|
-
const valueAsPrimitive = "" + value;
|
|
83
|
-
if (value === null) {
|
|
84
|
-
result.issue(new Syntax_PropertyNullIssue(context, propDef.name));
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
JSON.parse(valueAsPrimitive);
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
result.issue(new Language_PropertyValue_Issue(context, propDef ? propDef.name : "unknown", valueAsPrimitive, "JSON"));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Check whether the string `value` is a correct LionWeb serializationFormatVersion.
|
|
95
|
-
* @param value
|
|
96
|
-
* @param result
|
|
97
|
-
* @param context
|
|
98
|
-
*/
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
100
|
-
export function validateSerializationFormatVersion(value, result, context) {
|
|
101
|
-
if (typeof value !== "string") {
|
|
102
|
-
result.issue(new Syntax_SerializationFormatVersion_Issue(context, JSON.stringify(value)));
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (value.length === 0) {
|
|
106
|
-
result.issue(new Syntax_SerializationFormatVersion_Issue(context, value));
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=ValidationFunctions.js.map
|