diff options
author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-02-20 11:33:02 +0000 |
---|---|---|
committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-02-20 11:51:46 +0000 |
commit | c490e410af086fa89f40d515505bba02a08168f3 (patch) | |
tree | ce68fc055f0f93e2bc1e7ac57d997b7943b53f15 /django/contrib/postgres/fields/array.py | |
parent | 32d4db66b999cde6776d4be7f71528dab94916cc (diff) | |
download | django-c490e410af086fa89f40d515505bba02a08168f3.tar.gz |
Fixed #24373 -- Added run_validators to ArrayField.
Thanks to DavidMuller for the report.
Diffstat (limited to 'django/contrib/postgres/fields/array.py')
-rw-r--r-- | django/contrib/postgres/fields/array.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index 8e442c4a7a..970355fd62 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -139,6 +139,18 @@ class ArrayField(Field): code='nested_array_mismatch', ) + def run_validators(self, value): + super(ArrayField, self).run_validators(value) + for i, part in enumerate(value): + try: + self.base_field.run_validators(part) + except exceptions.ValidationError as e: + raise exceptions.ValidationError( + string_concat(self.error_messages['item_invalid'], ' '.join(e.messages)), + code='item_invalid', + params={'nth': i}, + ) + def formfield(self, **kwargs): defaults = { 'form_class': SimpleArrayField, |