summaryrefslogtreecommitdiff
path: root/django/core/validators.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-02-25 20:01:08 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-02-25 20:01:08 +0000
commit8a70334640b31229d53e982bd59d951fe15aecbc (patch)
tree793c50ad4f6fea8de6507672aa123adade5f3abf /django/core/validators.py
parent43829a95d3e5740250794a0b4400fd813e724a2e (diff)
newforms-admin: Merged to [4579]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4580 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/validators.py')
-rw-r--r--django/core/validators.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index a2f3dc3bc3..ebfbd3961e 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -312,11 +312,12 @@ class RequiredIfOtherFieldGiven(RequiredIfOtherFieldsGiven):
RequiredIfOtherFieldsGiven.__init__(self, [other_field_name], error_message)
class RequiredIfOtherFieldEquals(object):
- def __init__(self, other_field, other_value, error_message=None):
+ def __init__(self, other_field, other_value, error_message=None, other_label=None):
self.other_field = other_field
self.other_value = other_value
+ other_label = other_label or other_value
self.error_message = error_message or lazy_inter(gettext_lazy("This field must be given if %(field)s is %(value)s"), {
- 'field': other_field, 'value': other_value})
+ 'field': other_field, 'value': other_label})
self.always_test = True
def __call__(self, field_data, all_data):
@@ -324,11 +325,12 @@ class RequiredIfOtherFieldEquals(object):
raise ValidationError(self.error_message)
class RequiredIfOtherFieldDoesNotEqual(object):
- def __init__(self, other_field, other_value, error_message=None):
+ def __init__(self, other_field, other_value, other_label=None, error_message=None):
self.other_field = other_field
self.other_value = other_value
+ other_label = other_label or other_value
self.error_message = error_message or lazy_inter(gettext_lazy("This field must be given if %(field)s is not %(value)s"), {
- 'field': other_field, 'value': other_value})
+ 'field': other_field, 'value': other_label})
self.always_test = True
def __call__(self, field_data, all_data):