Skip to content

Instantly share code, notes, and snippets.

@ViktorStiskala
Created March 24, 2017 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ViktorStiskala/cd7e64f9f1a0a0cad6d00db3b0865367 to your computer and use it in GitHub Desktop.
Save ViktorStiskala/cd7e64f9f1a0a0cad6d00db3b0865367 to your computer and use it in GitHub Desktop.
def validate_account_number(value):
checksum = sum(int(value[i]) * (8-i) for i in range(7)) % 11
last_digit = int(value[-1])
if checksum in [0, 10]:
c = 1
elif checksum == 1:
c = 0
else:
c = 11 - checksum
if last_digit != c:
raise ValidationError(self.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment