summaryrefslogtreecommitdiff
path: root/django/core/validators.py
diff options
context:
space:
mode:
authorbuzzi <buzzi.javier@gmail.com>2018-10-17 14:52:19 +0000
committerTim Graham <timograham@gmail.com>2018-10-22 10:26:54 -0400
commit24cae0bedc51093b363c323af555946a8edea1a1 (patch)
tree39afc03c2f0ee34844ae383d1044e89e2607c726 /django/core/validators.py
parent5e3463f6bcec818431f0e1f4649d6a5bd944c459 (diff)
downloaddjango-24cae0bedc51093b363c323af555946a8edea1a1.tar.gz
Fixed #29860 -- Allowed BaseValidator to accept a callable limit_value.
Diffstat (limited to 'django/core/validators.py')
-rw-r--r--django/core/validators.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index c1c9cd1c87..38e4b6aa1d 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -317,8 +317,9 @@ class BaseValidator:
def __call__(self, value):
cleaned = self.clean(value)
- params = {'limit_value': self.limit_value, 'show_value': cleaned, 'value': value}
- if self.compare(cleaned, self.limit_value):
+ limit_value = self.limit_value() if callable(self.limit_value) else self.limit_value
+ params = {'limit_value': limit_value, 'show_value': cleaned, 'value': value}
+ if self.compare(cleaned, limit_value):
raise ValidationError(self.message, code=self.code, params=params)
def __eq__(self, other):