python - More than one arguments for a single keyword -
loanwolf_bank_accounts_length = { '001': 7, # banque de montréal '002': 7, # scotia '003': 7, # rbc '004': 7 or 11, # td (7 or 11) '006': 7, # bnc '010': 7, # cibc '016': 9, # hsbc '039': 9, # banque laurentienne '614': 10, # tangerine '815': 7, # desjardins '829': 7, # desjardins ontario }
and
def clean_bank_account(self): bank_account = self.form.cleaned_data.get('bank_account') bank_transit = self.form.cleaned_data.get('bank_transit') if bank_account not in (none, ''): bank = self.form.cleaned_data.get('bank') if bank not in (none, ''): # check bank account format specific banks length = settings.loanwolf_bank_accounts_length.get(bank) if length: if bank_transit not in (none, ''): if not bank_account.isnumeric() or length != len(bank_account): if bank == '004': raise validationerror( _('bank account number must contain 7 or 11 digits') % length # noqa ) else: raise validationerror( _('bank account number must contain %d digits') % length # noqa ) else: raise validationerror( _('cannot validate bank account without valid bank transit') # noqa ) return bank_account
i wanted give more 1 arguments, definitions 004
if length
different of 7 or 11, want display bank account number must contain 7 or 11 digits
. how pass more 1 arguments keyword?
use list or tuple instead of integer values in dictionary.
loanwolf_bank_accounts_length = { '001': [7], # banque de montréal '002': [7], # scotia '003': [7], # rbc '004': [7, 11], # td (7 or 11) '006': [7], # bnc '010': [7], # cibc '016': [9], # hsbc '039': [9], # banque laurentienne '614': [10], # tangerine '815': [7], # desjardins '829': [7], # desjardins ontario }
you need change of logic in clean_bank_account
too.
Comments
Post a Comment