def clean(self, value): """Raises a ValidationError if the card is not valid and stashes card type.""" value = super(CreditCardField, self).clean(value) self.card_type = verify_credit_card(value) if self.card_type is None: raise forms.ValidationError("Invalid credit card number.") return value
def clean(self, value): """Raises a ValidationError if the card is not valid and stashes card type.""" if value: self.card_type = verify_credit_card(value) if self.card_type is None: raise forms.ValidationError("Invalid credit card number.") return value
def clean(self, value): """Raises a ValidationError if the card is not valid and stashes card type.""" if value: value = value.replace('-', '').replace(' ', '') self.card_type = verify_credit_card(value) if self.card_type is None: raise forms.ValidationError("Invalid credit card number.") return value
def clean(self, value): """Raises a ValidationError if the card is not valid and stashes card type.""" value = value or '' value = value.replace('-', '').replace(' ', '') self.card_type = verify_credit_card(value) if self.card_type is None: raise forms.ValidationError("Invalid credit card number.") return value
def clean(self, value): """ Raises a ValidationError if the card is not valid. Also sets card type! """ card_type = verify_credit_card(value) if card_type is None: raise forms.ValidationError("Invalid credit card number.") self.card_type = card_type return value
def clean(self, value): """ Raises if it's an invalid card. Also sets the card_type. """ card_type = verify_credit_card(value) if card_type is None: raise forms.ValidationError("Invalid credit card number.") self.card_type = card_type return value