Skip to content

Commit

Permalink
Use plain exception string when throwing django ValidationError
Browse files Browse the repository at this point in the history
Closes #77
  • Loading branch information
surenkov committed Jan 14, 2025
1 parent 0a0ba97 commit 104246c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django_pydantic_field/v1/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def to_python(self, value) -> "base.SchemaT":
assert self.decoder is not None
return self.decoder().decode(value)
except pydantic.ValidationError as e:
raise django_exceptions.ValidationError(e.errors())
raise django_exceptions.ValidationError(str(e)) from e

def get_prep_value(self, value):
if not self._is_prepared_schema:
Expand Down
3 changes: 1 addition & 2 deletions django_pydantic_field/v2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def to_python(self, value: ty.Any):
try:
return self.adapter.validate_python(value)
except pydantic.ValidationError as exc:
error_params = {"errors": exc.errors(), "field": self}
raise exceptions.ValidationError(exc.json(), code="invalid", params=error_params) from exc
raise exceptions.ValidationError(str(exc), code="invalid") from exc

def get_prep_value(self, value: ty.Any):
value = self._prepare_raw_value(value)
Expand Down

0 comments on commit 104246c

Please sign in to comment.