-
-
Save marlncpe/bd29d3851635bd99e1b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean_cedula(self): | |
""" | |
Valída que sea Correcta la Cédula | |
""" | |
ced = self.cleaned_data['cedula'] | |
msg = "La Cédula introducida no es válida" | |
valores = [ int(ced[x]) * (2 - x % 2) for x in range(9) ] | |
suma = sum(map(lambda x: x > 9 and x - 9 or x, valores)) | |
veri = 10 - (suma - (10 * (suma / 10))) | |
if int(ced[9]) == int(str(veri)[-1:]): | |
return ced | |
else: | |
raise forms.ValidationError(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment