MCPcopy
hub / github.com/django/django / validate

Method validate

django/contrib/postgres/fields/array.py:205–222  ·  view source on GitHub ↗
(self, value, model_instance)

Source from the content-addressed store, hash-verified

203 return SliceTransformFactory(start, end)
204
205 def validate(self, value, model_instance):
206 super().validate(value, model_instance)
207 for index, part in enumerate(value):
208 try:
209 self.base_field.validate(part, model_instance)
210 except exceptions.ValidationError as error:
211 raise prefix_validation_error(
212 error,
213 prefix=self.error_messages["item_invalid"],
214 code="item_invalid",
215 params={"nth": index + 1},
216 )
217 if isinstance(self.base_field, ArrayField):
218 if len({len(i) for i in value}) > 1:
219 raise exceptions.ValidationError(
220 self.error_messages["nested_array_mismatch"],
221 code="nested_array_mismatch",
222 )
223
224 def run_validators(self, value):
225 super().run_validators(value)

Callers

nothing calls this directly

Calls 1

prefix_validation_errorFunction · 0.90

Tested by

no test coverage detected