I think the best option is for you to write the validator itself and add it to your settings.py
. Here in Django's doc you can see how, but it would be something like this draft I made below (I just added an example, missing all validation methods):
from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _
class MyCustomValidator:
def __init__(self):
self.length = 10
self.max_upper_case = 2
self.max_lower_case = 2
self.max_int_case = 1
self.max_symbols_case = 2
def validate_length_password(self, password):
if len(self.password) < self.length:
return True
return False
def validate_upper_case(self, password):
pass
def validate_lower_case(self, password):
pass
def validate_int_case(self, password):
pass
def validate_max_symbols_case(self, password):
pass
def validate(self, password, user=None):
if self.validate_length_password(password):
raise ValidationError(
_("This password must contain at least "
"%(length)d characters."),
code='password_too_short',
params={'length': self.length},
)
def get_help_text(self):
return _(
"Your password must contain at least %(length)d characters."
% {'length': self.length}
)
From there on your settings.py
on AUTH_PASSWORD_VALIDATORS
you add this class, type:
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'path.onde.ta.o.arquivo.do.seu.validator.finalizando.com.a.classe.MyCustomValidator',
},
]