Validators
- terminusgps.authorizenet.validators.validate_credit_card_expiry_month(value: str) → None[source]
Raises
ValidationError
if the value is an invalid credit card expiration date month.
- terminusgps.authorizenet.validators.validate_credit_card_expiry_year(value: str) → None[source]
Raises
ValidationError
if the value is an invalid credit card expiration date year.
- terminusgps.authorizenet.validators.validate_credit_card_number(value: str) → None[source]
Raises
ValidationError
if the value is an invalid credit card number.Uses the Luhn algorithm to validate the credit card number.
Usage
from django import forms
from terminusgps.authorizenet.validators import (
validate_credit_card_number,
validate_credit_card_expiry_month,
validate_credit_card_expiry_year,
)
class CreditCardForm(forms.Form):
# Adding the validators to a form field renders error messages properly
cc_number = forms.CharField(
max_length=17, validators=[validate_credit_card_number]
)
cc_expiry_month = forms.CharField(
max_length=2, validators=[validate_credit_card_expiry_month]
)
cc_expiry_year = forms.CharField(
max_length=2, validators=[validate_credit_card_expiry_year]
)