0001-widgets-more-flexible-validation-of-IBAN-fields-6712.patch
tests/test_widgets.py | ||
---|---|---|
1085 | 1085 |
# regular cases |
1086 | 1086 |
for iban in [ |
1087 | 1087 |
'BE71 0961 2345 6769', # Belgium |
1088 |
'be71 0961 2345 6769', # Lowercase |
|
1088 | 1089 |
'FR76 3000 6000 0112 3456 7890 189', # France |
1089 | 1090 |
'FR27 2004 1000 0101 2345 6Z02 068', # France (having letter) |
1090 | 1091 |
'DE91 1000 0000 0123 4567 89', # Germany |
... | ... | |
1113 | 1114 |
'FR76', |
1114 | 1115 |
'FR76 0000 0000 0000 0000 0000 000', |
1115 | 1116 |
'FR76 1234 4567', |
1116 |
'Fr76 3000 6000 0112 3456 7890 189', |
|
1117 | 1117 |
]: |
1118 | 1118 |
widget = WcsExtraStringWidget('test', value='foo', required=False) |
1119 | 1119 |
widget.field = fakefield |
wcs/qommon/form.py | ||
---|---|---|
1193 | 1193 |
'title': _('IBAN'), |
1194 | 1194 |
'function': 'validate_iban', |
1195 | 1195 |
'error_message': _('Invalid IBAN'), |
1196 |
'parse': lambda v: v.upper().strip().replace(' ', ''), |
|
1196 | 1197 |
}, |
1197 | 1198 |
), |
1198 | 1199 |
('regex', {'title': _('Regular Expression')}), |
... | ... | |
1364 | 1365 |
if self.value and self.validation_function and not self.validation_function(self.value): |
1365 | 1366 |
self.error = self.validation_function_error_message or _('invalid value') |
1366 | 1367 | |
1368 |
if self.field and self.value and not self.error and self.field.validation: |
|
1369 |
parser = ValidationWidget.validation_methods[self.field.validation['type']].get('parse') |
|
1370 |
if parser: |
|
1371 |
self.value = parser(self.value) |
|
1372 | ||
1367 | 1373 | |
1368 | 1374 |
class DateWidget(StringWidget): |
1369 | 1375 |
'''StringWidget which checks the value entered is a correct date''' |
wcs/qommon/misc.py | ||
---|---|---|
1001 | 1001 |
'''https://fr.wikipedia.org/wiki/International_Bank_Account_Number''' |
1002 | 1002 |
if not string_value: |
1003 | 1003 |
return False |
1004 |
string_value = string_value.upper().strip().replace(' ', '') |
|
1004 | 1005 |
country_code = string_value[:2] |
1005 | 1006 |
iban_key = string_value[2:4] |
1006 | 1007 |
bban = string_value[4:] |
1007 |
- |