Created
June 17, 2013 21:22
-
-
Save zodman/5800585 to your computer and use it in GitHub Desktop.
pasword enhanced, stupid whim
This file contains hidden or 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_password2(self): | |
import string | |
password1 = self.cleaned_data.get("password1", "") | |
password2 = self.cleaned_data["password2"] | |
if password1 != password2: | |
raise forms.ValidationError(_("The two password fields didn't match.")) | |
if len(password2) <6: | |
raise forms.ValidationError(_("The password must be almost 6 chars")) | |
digits, chars, punt = set(), set(), set() | |
for i in password2: | |
if i.isdigit(): | |
digits.add(i) | |
if ord(i) < 128: | |
chars.add(i) | |
if i in string.punctuation: | |
punt.add(i) | |
if not len(digits) >=1 or not len(chars)>=1 or not len(punt)>=1: | |
raise forms.ValidationError(_("One char, one digit or one puntaction required")) | |
return password2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment