mobui / gs1_barcode_parser

MIT License
5 stars 10 forks source link

Data format mismatch #11

Closed RafaRuiz closed 1 month ago

RafaRuiz commented 1 month ago
Data format mismatch RegExp: pattern=^01(\d{14})$ flags= for AI 01

for value: 0150602641158911020414891725122811210101

sachebotarev commented 1 month ago

Hi GS1 Application Identifier 01 Must be 14 characters long (see https://ref.gs1.org/ai/01). In our example length is 13

image

RafaRuiz commented 1 month ago

It makes sense. Yet I've got a medical product with 13 characters, which barcode is ean13 and is the same than the one from after 01 to . Is it possible to parse ignoring the GS1-01?

sachebotarev commented 1 month ago

Hi, I have added the ability to define custom AI to the library (version 1.1.0). Custom element have highest priority Now you can add your own description of an AI element that conflicts with the standard. Look at the test custom_ai_test.dart, I took your example as a basis

     final parser =
        GS1BarcodeParser.configurableParser(GS1BarcodeParserConfig(customAIs: {
      '01': const AI(
        code: '01',
        fixLength: 13,
        type: AIFormatType.FIXED_LENGTH,
        dataTitle: 'GTIN',
        regExpString: r'^01(\d{13})$',
        description: 'EAN13',
      ),
    }));

Test it, please

RafaRuiz commented 1 month ago

All good, I guess I'll enable an use case with several parsers. Thanks.