We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1080baa commit a5eec52Copy full SHA for a5eec52
1 file changed
barcode/ean.py
@@ -41,6 +41,9 @@ def __init__(self, ean, writer=None):
41
ean = ean[:self.digits]
42
if not ean.isdigit():
43
raise IllegalCharacterError('EAN code can only contain numbers.')
44
+ if len(ean) != self.digits:
45
+ raise NumberOfDigitsError('EAN must have {0} digits, not '
46
+ '{1}.'.format(self.digits, len(ean)))
47
self.ean = ean
48
self.ean = '{0}{1}'.format(ean, self.calculate_checksum())
49
self.writer = writer or Barcode.default_writer()
0 commit comments