mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Fixed barcodes validation problem
This commit is contained in:
23
src/pass.js
23
src/pass.js
@@ -363,14 +363,23 @@ class Pass {
|
|||||||
data = [data];
|
data = [data];
|
||||||
}
|
}
|
||||||
|
|
||||||
// messageEncoding is required but has a default value.
|
// Stripping from the array not-object elements, objects with no message
|
||||||
// Therefore I assign a validated version of the object with the default value
|
// and the ones that does not pass validation.
|
||||||
// to the ones that doesn't have messageEncoding.
|
// Validation assign default value to missing parameters (if any).
|
||||||
// if o is not a valid object, false is returned and then filtered later
|
|
||||||
|
|
||||||
let valid = data
|
let valid = data.reduce((acc, current) => {
|
||||||
.map(o => schema.getValidated(o, "barcode"))
|
if (!(current && current instanceof Object && current.hasOwnProperty("message"))) {
|
||||||
.filter(o => !!Object.keys(o).length);
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
let validated = schema.getValidated(current, "barcode");
|
||||||
|
|
||||||
|
if (!(validated && validated instanceof Object && Object.keys(validated).length)) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...acc, validated];
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (valid.length) {
|
if (valid.length) {
|
||||||
this._props["barcode"] = valid[0];
|
this._props["barcode"] = valid[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user