Skip to content

Commit acb8eb8

Browse files
committed
Added templatelist.fastiot.yaml validation
1 parent 79ef088 commit acb8eb8

26 files changed

+333
-139
lines changed

package-lock.json

Lines changed: 144 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,13 @@
696696
"compare-versions": "^6.0.0",
697697
"fs-extra": "^11.1.1",
698698
"ip": "^1.1.8",
699-
"local-devices": "^3.0.0",
699+
"local-devices": "^4.0.0",
700700
"pingman": "^2.0.0",
701701
"platform-folders": "^0.6.0",
702702
"ssh2": "^1.13.0",
703703
"ssh2-promise": "^1.0.3",
704704
"tcp-port-used": "^1.0.2",
705-
"utimes": "^4.0.4",
705+
"utimes": "^5.1.1",
706706
"uuid": "^9.0.0",
707707
"xmldom": "^0.6.0",
708708
"xpath": "0.0.32",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# for https://www.npmjs.com/package/yaml-schema-validator-fork
2+
entities:
3+
- id:
4+
type: string
5+
required: true
6+
version:
7+
type: string
8+
required: true
9+
forVersionExt:
10+
type: string
11+
required: true
12+
platform:
13+
- type: string
14+
required: true

src/Entity/EntityBase.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ export abstract class EntityBase<T extends EntityBaseAttribute> {
3131
protected _validationErrors:Array<string>=[];
3232
public get ValidationErrors(): Array<string> {
3333
return this._validationErrors;}
34-
35-
public get ValidationErrorsToString(): string {
36-
let msg=`Validation messages:`;
37-
let index=1;
38-
this._validationErrors.forEach((item) => {
39-
msg=`${msg}\n${index}. ${item}`;
40-
index++;
41-
});
42-
return msg;}
4334
public Attributes: T;
4435
public Type:EntityType=EntityType.none;
4536

@@ -90,7 +81,7 @@ export abstract class EntityBase<T extends EntityBaseAttribute> {
9081
//checking folder structure
9182
//FilesValidator
9283
let filesValidator=new FilesValidator(this._pathFolderSchema);
93-
let result = filesValidator.ValidateFiles(this.RootDir,this._fileNameSchemaDirStructure);
84+
let result = filesValidator.ValidateDirStructureBySchema(this.RootDir,this._fileNameSchemaDirStructure);
9485
const validationErrors=<Array<string>>result.returnObject;
9586
this._validationErrors = validationErrors.slice();
9687
//check if folder matches entity and id

src/Entity/EntityBaseAttribute.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@ export class EntityBaseAttribute {
1212
private _version:string="";
1313
public get Version(): string {
1414
return this._version;}
15-
private _platform:Array<string>=[];
16-
public get platform(): Array<string> {
17-
return this._platform;}
1815
private _releaseDate:Date=new Date();
1916
public get ReleaseDate(): Date {
2017
return this._releaseDate;}
21-
private _forVersionExt:string="";
22-
public get ForVersionExt(): string {
23-
return this._forVersionExt;}
2418
private _author:string="";
2519
public get Author(): string {
2620
return this._author;}
@@ -31,9 +25,12 @@ export class EntityBaseAttribute {
3125
private _description:string="";
3226
public get Description(): string {
3327
return this._description;}
34-
private _language:string="";
35-
public get Language(): string {
36-
return this._language;}
28+
private _forVersionExt:string="";
29+
public get ForVersionExt(): string {
30+
return this._forVersionExt;}
31+
private _platform:Array<string>=[];
32+
public get platform(): Array<string> {
33+
return this._platform;}
3734
private _endDeviceArchitecture:Array<string>=[];
3835
public get EndDeviceArchitecture(): Array<string> {
3936
return this._endDeviceArchitecture;}
@@ -84,7 +81,6 @@ export class EntityBaseAttribute {
8481
this.Label=obj.label;
8582
this._detail=obj.detail;
8683
this._description=obj.description;
87-
this._language=obj.language;
8884
//arrays
8985
let index=0;
9086
//platform
@@ -148,7 +144,7 @@ export class EntityBaseAttribute {
148144
}
149145
//YamlValidator
150146
let yamlValidator:IYamlValidator=new YamlValidatorFork(this._pathFolderSchema);
151-
let result = yamlValidator.ValidateSchema(yamlFilePath,this._fileNameSchemaRootYaml);
147+
let result = yamlValidator.ValidateFileBySchema(yamlFilePath,this._fileNameSchemaRootYaml);
152148
const validationErrors=<Array<string>>result.returnObject;
153149
this._validationErrors = validationErrors.slice();
154150
}

0 commit comments

Comments
 (0)