Skip to content

Commit

Permalink
feat(Pydantic): honor hide_input_in_errors in throwing validation exc…
Browse files Browse the repository at this point in the history
…eptions
  • Loading branch information
charles-dyfis-net committed Oct 29, 2024
1 parent 017464f commit cfa38a0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion litestar/contrib/pydantic/pydantic_init_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def _dec_pydantic_v2(model_type: type[pydantic_v2.BaseModel], value: Any, strict
try:
return model_type.model_validate(value, strict=strict)
except pydantic_v2.ValidationError as e:
raise ExtendedMsgSpecValidationError(errors=cast("list[dict[str, Any]]", e.errors())) from e
hide_input = False
if isinstance(model_config := getattr(model_type, "model_config", None), dict):
hide_input = bool(model_config.get("hide_input_in_errors"))
raise ExtendedMsgSpecValidationError(
errors=cast("list[dict[str, Any]]", e.errors(include_input=not hide_input))
) from e


def _dec_pydantic_uuid(
Expand Down

0 comments on commit cfa38a0

Please sign in to comment.