Changed _validateType to validate also the schema;

Edited schemas to comply with boardingPass requirements and the others pass types
This commit is contained in:
alexandercerutti
2018-07-25 17:05:23 +02:00
parent 1c68623596
commit ea8baec2b5
2 changed files with 24 additions and 8 deletions

View File

@@ -208,8 +208,14 @@ class Pass {
_validateType(passBuffer) {
try {
let passFile = JSON.parse(passBuffer.toString("utf8"));
let index = this.passTypes.findIndex(passType => passFile.hasOwnProperty(passType));
return this.passTypes.some(passType => passFile.hasOwnProperty(passType));
if (index == -1) {
return false;
}
let type = this.passTypes[index];
return schema.isValid(passFile[type], schema.constants[(type === "boardingPass" ? "boarding" : "basic") + "Structure"]);
} catch (e) {
return false;
}