def _validated(self, value): try: BankCard.validate_card_number(value) except ValueError: raise ValidationError(u'该银行卡号无效,请修改后重试') return value
def __call__(self, form, field): message = field.gettext(self.message) try: BankCard.validate_card_number(field.data) except ValueError: raise wtforms.validators.ValidationError(message)