Skip to content
masterclass Buddy

Pydantic · Pipe

str_strip_whitespace

str_strip_whitespace=True removes leading and trailing whitespace from Pydantic string fields during validation. Set it in the model's ConfigDict.

Last updated

Syntax

model_config = ConfigDict(str_strip_whitespace=True)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • str_to_lower
  • str_to_upper
  • str_min_length
  • str_max_length
  • ConfigDict

Source: Configuration | Pydantic Docs. Checked 2026-11-03.