Skip to content

Reject an over-long EAN or UPC code - #227

Open
SashaMIT wants to merge 1 commit into
picqer:mainfrom
SashaMIT:codered-ean-length
Open

SashaMIT wants to merge 1 commit into
picqer:mainfrom
SashaMIT:codered-ean-length

Conversation

@SashaMIT

Copy link
Copy Markdown

Summary

TypeEanUpcBase pads a short code up to the data length, then checks the digit at that position. A longer code is not rejected. getBarcode("08123172389739") succeeded because digit 13 is the real EAN-13 check digit and the extra 9 was kept.

A code longer than the symbology now throws InvalidLengthException. 081231723897 still becomes 0812317238973. The same cap applies to EAN-8 and UPC-A.

Test plan

  • On main, testEan13RejectsAnExtraDigit fails because no exception is thrown
  • After the length check, vendor/bin/phpunit passes

Made with Cursor

getBarcode("08123172389739") succeeded. EAN-13 is 13 digits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant