File tree 2 files changed +12
-2
lines changed 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -104,9 +104,11 @@ def validate(number, check_country=True):
104
104
mod_97_10 .validate (number [4 :] + number [:4 ])
105
105
# look up the number
106
106
info = _ibandb .info (number )
107
+ if not info [0 ][1 ]:
108
+ raise InvalidComponent ()
107
109
# check if the bban part of number has the correct structure
108
110
bban = number [4 :]
109
- if not _struct_to_re (info [0 ][1 ].get ('bban' , '- ' )).match (bban ):
111
+ if not _struct_to_re (info [0 ][1 ].get ('bban' , '' )).match (bban ):
110
112
raise InvalidFormat ()
111
113
# check the country-specific module if it exists
112
114
if check_country :
Original file line number Diff line number Diff line change @@ -31,7 +31,15 @@ country code is unknown and the checksum is still valid.
31
31
>>> iban.validate('0001')
32
32
Traceback (most recent call last):
33
33
...
34
- InvalidFormat: ...
34
+ InvalidComponent: ...
35
+
36
+
37
+ IBAN for an unknown country code.
38
+
39
+ >>> iban.validate('XX431234')
40
+ Traceback (most recent call last):
41
+ ...
42
+ InvalidComponent: ...
35
43
36
44
37
45
These should all be valid numbers and are from the IBAN REGISTRY as sample
You can’t perform that action at this time.
0 commit comments