mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-16 04:25:34 +00:00
Changed _validateType to validate also the schema;
Edited schemas to comply with boardingPass requirements and the others pass types
This commit is contained in:
8
index.js
8
index.js
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user