Validators

terminusgps.validators.validate_credit_card_expiry_month(value: str) None[source]

Raises ValidationError if the value is an invalid credit card expiration date month.

Parameters:

value (str) – A credit card expiration month.

Raises:
Returns:

Nothing.

Return type:

None

terminusgps.validators.validate_credit_card_expiry_year(value: str) None[source]

Raises ValidationError if the value is an invalid credit card expiration date year.

Parameters:

value (str) – A credit card expiration year.

Raises:
Returns:

Nothing.

Return type:

None

terminusgps.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.

Parameters:

value (str) – A credit card number.

Raises:
  • ValidationError – If the credit card number contained non-digit characters.

  • ValidationError – If the credit card number failed the Luhn algorithm check.

Returns:

Nothing.

Return type:

None

terminusgps.validators.validate_e164_phone_number(value: str) None[source]

Raises ValidationError if the value is not a valid E.164 formatted phone number.

  • Country Code: A 2-5 character code with a leading ‘+’ indicating the phone number’s destination country.

  • Area Code: The first 3 digits of the phone number.

  • Subscriber Number: The last 7 digits of the phone number.

Parameters:

value (str) –

A phone number in E.164 format.

Raises:
  • ValidationError – If the phone number wasn’t provided.

  • ValidationError – If the phone number didn’t start with a ‘+’ character.

  • ValidationError – If the phone number contained any number of spaces.

  • ValidationError – If the phone number contained any number of hyphens.

  • ValidationError – If the phone number was less than 12 characters in length.

  • ValidationError – If the phone number was greater than 15 characters in length.

  • ValidationError – If the country code was invalid.

  • ValidationError – If the area code wasn’t exactly 3 characters in length.

  • ValidationError – If the area code wasn’t a digit.

  • ValidationError – If the subscriber number (non-area code number) wasn’t exactly 7 characters in length.

  • ValidationError – If the subscriber number (non-area code number) wasn’t a digit.

Returns:

Nothing.

Return type:

None