Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too strict: Unable to parse '000000' date #247

Closed
silentbugs opened this issue Dec 15, 2023 · 4 comments · Fixed by #386
Closed

Too strict: Unable to parse '000000' date #247

silentbugs opened this issue Dec 15, 2023 · 4 comments · Fixed by #386
Labels
breaking Backwards incompatible change enhancement New feature or request

Comments

@silentbugs
Copy link

Hello!

Some of the GS1 barcodes I am scanning contain some silly dates, such as '000000'. Currently parsing fails completely, as month 0 and day 0 are not a valid month/day respectively.

Is it possible to decide how certain errors are handled, and if they should fallback to defaults or fail completely?

Example of a GS1 barcode that fails: 019906600092731431030078881500000010215359

@jodal
Copy link
Owner

jodal commented Dec 17, 2023

Currently, Biip has no configuration options for making the parsing more lenient. It follows the GS1 specifications quite strictly.

However, being able to control Biip's strictness has surfaced as a request several times now, so I think this is the highest prioritized item for any further development of Biip.

@silentbugs
Copy link
Author

Thanks for the swift reply. I really like libraries that are strict with specs, so thanks for doing this.

I will probably end up using biip because it seems like a great library and since I'll have to find a way to parse such barcodes I'll probably fork it and write a PR for this.

I was thinking of writing a class with most of the things currently defined in biip (such as _parse_date()), so that users import that class and configuring it, should they need to. Importing parse directly will give you the parse method with the defaults, as it currently works.

Any thoughts?

@jodal jodal added enhancement New feature or request breaking Backwards incompatible change labels Jul 29, 2024
@jodal jodal changed the title Unable to parse '000000' date Too strict: Unable to parse '000000' date Jul 29, 2024
@jodal jodal closed this as completed in 78117c7 Mar 23, 2025
@jodal
Copy link
Owner

jodal commented Mar 23, 2025

PR #385 moved all configuration flags to a configuration object. This means that we can now easily add more configuration options without having to pass the new flags through several layers of indirection.

PR #386 added a new configuration option gs1_message_verify_date that can be used to make Biip ignore GS1 messages with dates that are invalid. This will be part of the upcoming v4.0 release.

Feel free to open more issues if you have other cases where Biip needs to be less strict.

@jodal
Copy link
Owner

jodal commented Apr 7, 2025

This has been released in Biip 4.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Backwards incompatible change enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants