diff --git a/python/pydantic_core/core_schema.py b/python/pydantic_core/core_schema.py index a2f4b4f0c..2cb875b23 100644 --- a/python/pydantic_core/core_schema.py +++ b/python/pydantic_core/core_schema.py @@ -752,6 +752,7 @@ class StringSchema(TypedDict, total=False): to_upper: bool regex_engine: Literal['rust-regex', 'python-re'] # default: 'rust-regex' strict: bool + coerce_numbers_to_str: bool ref: str metadata: Any serialization: SerSchema diff --git a/src/validators/string.rs b/src/validators/string.rs index ab6671c9c..a7becf6bb 100644 --- a/src/validators/string.rs +++ b/src/validators/string.rs @@ -208,6 +208,7 @@ impl StrConstrainedValidator { || self.strip_whitespace || self.to_lower || self.to_upper + || self.coerce_numbers_to_str } }