From a2101796ef8f8980fbedb8a12188dbba88abca94 Mon Sep 17 00:00:00 2001 From: Milad Gholamrezaei Date: Tue, 9 Jun 2020 17:17:31 +0430 Subject: [PATCH] created PasswordValidator class --- rest_framework/validators.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rest_framework/validators.py b/rest_framework/validators.py index a5cb75a84..94c7542ce 100644 --- a/rest_framework/validators.py +++ b/rest_framework/validators.py @@ -30,6 +30,25 @@ def qs_filter(queryset, **kwargs): return queryset.none() +class PasswordValidator: + """ + This validator uses default django password validation function + django validator validates value with AUTH_PASSWORD_VALIDATORS in settings.py + + The message with the key of field name will be generated automatically in function. + + Should be applied to an individual field on the serializer. + + If the password is valid, return ``None``. + """ + + def __init__(self, validators=None, user=None): + self.validators = validators + self.user = user + + + + class UniqueValidator: """ Validator that corresponds to `unique=True` on a model field.