-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Status: rough draft
We've got country-specific price/weight normalization logic implemented in Questionmark's Hoard system for the Netherlands and (IIRC) Belgium. A PR can start by extracting the logic and sharing it.
Design idea:
- Barcodes must be able to self-identify the country they are intended for. This breaks down into official rules and our own QM-specific rules. Speculative: implement
GTIN::Base#countrywith official rules and possibly see if we can get this merged into upstream barcodevalidation when we have a working implementation.- Our custom classes may not be able to deterministically return a country.
- Implement
GTIN::Base#normalize(country: self.country)which we can use to implement normalization rules. Probably use a helper class per country. Return true/false based on whether normalization could happen or not. We can implement a#normalize!version that raises an error when we don't know the country or are unable to normalize.- The optional
countryargument helps to provide external information about the country a barcode "belongs" to.
- The optional
- Implement a
#normalized?method that can check if it's normalized or not. I'm unsure what's desired behavior for barcodes that we don't know the normalization behavior for. Do we also need to implement#can_normalize?to make this deterministic?
Metadata
Metadata
Assignees
Labels
No labels