-
Notifications
You must be signed in to change notification settings - Fork 1
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
Replace iso3166list with multiple optional iso3166 #9
Comments
We have a similar issues with minimum/specific lengths with AIs such as (8007) " I've never considered the current behaviour to be a problem since we provide the linters, as well as reference code (the Syntax Engine) for how to apply them, so code that is concerned only with structural validation can be easily enhanced. If people wanted a structure-only solution then maybe they could resort to the published regexs instead. Nevertheless, I'm still tempted by the suggested The suggested syntax works in the specific cases that you mention, but we have to be very careful about introducing a syntax that selects between more than a single optional component since it may easily lead to ambiguity, e.g. when the linters or character sets differ. Given We must carefully assert that the validation process involves a left to right match against each component of the AI's format specification for consecutive format-defined-size prefixes of the given data, declaring success if only optional components remain when we run out of data. I've pushed a Syntax Dictionary update (currently with another test AI (85)) as well as some corresponding unit tests to a "multi-optional" branch of the Syntax Engine: gs1/gs1-syntax-engine@2c765a6 The existing Syntax Engine code already does everything you would expect when it encounters multiple optional trailing components. It also survives fuzzing which generally is a good way of finding unexpected issues with changes of syntax. I'll give it some more thought and see if anything comes up. I would feel more reassured by the approach if we can introduce constraints into the GenSpecs for the AI system as a whole: Either (preferably), forbid AIs from being defined with multiple optional components (currently there is only ever one optional final component) so that we are free to define fine-grained substructure in the BSR without fear of the syntax clashing with the GenSpecs in the future. This is the status quo, but I have not see it codified anywhere, so it's not clear whether it will remain so. Or (less ideal), define that (1) all optional components must be at the end of the format specification (just as is currently the case) and that (2) all non-terminal components, whether mandatory or optional, must have fixed lengths (plainly obvious to avoid ambiguity). Then define a single correct matching action for the case of multiple optional components — preferably using left-to-right matching described above, and certainly not resorting to a "feasibility check" in order to resolve ambiguity. All current AI definitions already satisfy both of the above constraint scenarios. Therefore any agreed restrictions are design constraints for future work and do not change the current GS1 system. Without some codified constrains I think that we risk defining a behaviour for the BSR that gets redefined in the future by updates to the GenSpecs, possibly even with the GenSpec's behaviour being defined on an individual AI basis (for future AIs). This would not align with the BSRs existing notion of left-to-right componentisation. Whilst the alternative |
Done in 6d37ba2. Thanks for the suggestion. Leaving this open until we've captured the GS1 GenSpecs AI design constraints issue elsewhere. |
How would you like to approach the GenSpecs issue? I think the text above is a good foundation for a Work Request. |
@PetaDing-GS1 may be able to advise whether this can be bundled into the scope of any existing / planned work. Otherwise I'm certainly happy for someone to champion a new work item based on the above text. |
Following discussion, @PetaDing-GS1 to consider how to progress. |
The use of iso3166list is a problem for simple validators that are concerned only with structural validation (i.e., type and length). The way AIs 423 and 425 are defined, a structural validator would allow "1234" to pass.
gs1-syntax-dictionary/gs1-syntax-dictionary.txt
Lines 213 to 215 in ee18e07
I suggest these be rewritten using the optional terminology as follows:
An alternative would be to borrow the repetition syntax from regex:
The text was updated successfully, but these errors were encountered: