diff --git a/src/messages.ts b/src/messages.ts index 3ef035f..edf2266 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -25,6 +25,7 @@ const debugMessages: MessageGroup = { BRC_FORMATTYPE_UNMATCH: "Format must be a string or null. Cannot set backward compatibility.", BRC_AUTC_MISSING_DATA: "Unable to autogenerate barcodes. Data is not a string.", BRC_BW_FORMAT_UNSUPPORTED: "This format is not supported (by Apple) for backward support. Please choose another one.", + BRC_NO_POOL: "Cannot set barcode: no barcodes found. Please set barcodes first. Barcode is for retrocompatibility only.", DATE_FORMAT_UNMATCH: "%s was not set due to incorrect date format." }; diff --git a/src/pass.ts b/src/pass.ts index 16fb19a..6d8fc8d 100644 --- a/src/pass.ts +++ b/src/pass.ts @@ -415,6 +415,11 @@ export class Pass implements PassIndexSignature { return this; } + if (!(barcodes && barcodes.length)) { + barcodeDebug(formatMessage("BRC_NO_POOL")) + return this; + } + // Checking which object among barcodes has the same format of the specified one. const index = barcodes.findIndex(b => b.format.toLowerCase().includes(chosenFormat.toLowerCase()));