summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/validators.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /django/contrib/postgres/validators.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
downloaddjango-9c19aff7c7561e3a82978a272ecdaad40dda5c00.tar.gz
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'django/contrib/postgres/validators.py')
-rw-r--r--django/contrib/postgres/validators.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/django/contrib/postgres/validators.py b/django/contrib/postgres/validators.py
index db6205f356..df2bd88eb9 100644
--- a/django/contrib/postgres/validators.py
+++ b/django/contrib/postgres/validators.py
@@ -1,24 +1,29 @@
from django.core.exceptions import ValidationError
from django.core.validators import (
- MaxLengthValidator, MaxValueValidator, MinLengthValidator,
+ MaxLengthValidator,
+ MaxValueValidator,
+ MinLengthValidator,
MinValueValidator,
)
from django.utils.deconstruct import deconstructible
-from django.utils.translation import gettext_lazy as _, ngettext_lazy
+from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ngettext_lazy
class ArrayMaxLengthValidator(MaxLengthValidator):
message = ngettext_lazy(
- 'List contains %(show_value)d item, it should contain no more than %(limit_value)d.',
- 'List contains %(show_value)d items, it should contain no more than %(limit_value)d.',
- 'limit_value')
+ "List contains %(show_value)d item, it should contain no more than %(limit_value)d.",
+ "List contains %(show_value)d items, it should contain no more than %(limit_value)d.",
+ "limit_value",
+ )
class ArrayMinLengthValidator(MinLengthValidator):
message = ngettext_lazy(
- 'List contains %(show_value)d item, it should contain no fewer than %(limit_value)d.',
- 'List contains %(show_value)d items, it should contain no fewer than %(limit_value)d.',
- 'limit_value')
+ "List contains %(show_value)d item, it should contain no fewer than %(limit_value)d.",
+ "List contains %(show_value)d items, it should contain no fewer than %(limit_value)d.",
+ "limit_value",
+ )
@deconstructible
@@ -26,8 +31,8 @@ class KeysValidator:
"""A validator designed for HStore to require/restrict keys."""
messages = {
- 'missing_keys': _('Some keys were missing: %(keys)s'),
- 'extra_keys': _('Some unknown keys were provided: %(keys)s'),
+ "missing_keys": _("Some keys were missing: %(keys)s"),
+ "extra_keys": _("Some unknown keys were provided: %(keys)s"),
}
strict = False
@@ -42,35 +47,41 @@ class KeysValidator:
missing_keys = self.keys - keys
if missing_keys:
raise ValidationError(
- self.messages['missing_keys'],
- code='missing_keys',
- params={'keys': ', '.join(missing_keys)},
+ self.messages["missing_keys"],
+ code="missing_keys",
+ params={"keys": ", ".join(missing_keys)},
)
if self.strict:
extra_keys = keys - self.keys
if extra_keys:
raise ValidationError(
- self.messages['extra_keys'],
- code='extra_keys',
- params={'keys': ', '.join(extra_keys)},
+ self.messages["extra_keys"],
+ code="extra_keys",
+ params={"keys": ", ".join(extra_keys)},
)
def __eq__(self, other):
return (
- isinstance(other, self.__class__) and
- self.keys == other.keys and
- self.messages == other.messages and
- self.strict == other.strict
+ isinstance(other, self.__class__)
+ and self.keys == other.keys
+ and self.messages == other.messages
+ and self.strict == other.strict
)
class RangeMaxValueValidator(MaxValueValidator):
def compare(self, a, b):
return a.upper is None or a.upper > b
- message = _('Ensure that this range is completely less than or equal to %(limit_value)s.')
+
+ message = _(
+ "Ensure that this range is completely less than or equal to %(limit_value)s."
+ )
class RangeMinValueValidator(MinValueValidator):
def compare(self, a, b):
return a.lower is None or a.lower < b
- message = _('Ensure that this range is completely greater than or equal to %(limit_value)s.')
+
+ message = _(
+ "Ensure that this range is completely greater than or equal to %(limit_value)s."
+ )