misc: use list comprehensions to check for password character classes (#36515)

This commit is contained in:
Frédéric Péters 2019-11-13 00:32:37 +01:00
parent 1987c5407f
commit e541759a67
1 changed files with 4 additions and 4 deletions

View File

@ -2139,28 +2139,28 @@ $(function() {
set_errors.append(_('Password is too long. It must be at most %d characters.') % max_len)
count = self.count_uppercase
if len(filter(lambda c: c.isupper(), pwd1)) < count:
if len([x for x in pwd1 if x.isupper()]) < count:
set_errors.append(
ngettext('Password must contain an uppercase character.',
'Password must contain at least %(count)d uppercase characters.',
count) % {'count': count})
count = self.count_lowercase
if len(filter(lambda c: c.islower(), pwd1)) < count:
if len([x for x in pwd1 if x.islower()]) < count:
set_errors.append(
ngettext('Password must contain a lowercase character.',
'Password must contain at least %(count)d lowercase characters.',
count) % {'count': count})
count = self.count_digit
if len(filter(lambda c: c.isdigit(), pwd1)) < self.count_digit:
if len([x for x in pwd1 if x.isdigit()]) < self.count_digit:
set_errors.append(
ngettext('Password must contain a digit.',
'Password must contain at least %(count)d digits.',
count) % {'count': count})
count = self.count_special
if len(filter(lambda c: not c.isalnum(), pwd1)) < count:
if len([x for x in pwd1 if not x.isalnum()]) < count:
set_errors.append(
ngettext('Password must contain a special character.',
'Password must contain at least %(count)d special characters.',