Skip to content

Commit

Permalink
Small cleanup to KWCivilIDNumberField refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
benkonrath committed Nov 5, 2016
1 parent 98be50e commit 978d8d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions localflavor/kw/forms.py
Expand Up @@ -12,7 +12,7 @@
from django.utils.translation import gettext_lazy as _


def has_valid_checksum(value):
def kw_civil_id_number_has_valid_checksum(value):
weight = (2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2)
calculated_checksum = 0
for i in range(11):
Expand All @@ -34,6 +34,8 @@ class KWCivilIDNumberField(RegexField):
* The number consist of 12 digits.
* The birthdate of the person is a valid date.
* The calculated checksum equals to the last digit of the Civil ID.
.. versionchanged:: 1.4
"""
default_error_messages = {
'invalid': _('Enter a valid Kuwaiti Civil ID number'),
Expand Down Expand Up @@ -64,7 +66,7 @@ def clean(self, value):
except ValueError:
raise ValidationError(self.error_messages['invalid'])

if not has_valid_checksum(value):
if not kw_civil_id_number_has_valid_checksum(value):
raise ValidationError(self.error_messages['invalid'])

return value

0 comments on commit 978d8d8

Please sign in to comment.