Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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