Skip to content

Commit 4b82169

Browse files
authored
Add coerce_numbers_to_str option in StringSchema (#1262)
1 parent 683c5a3 commit 4b82169

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

python/pydantic_core/core_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ class StringSchema(TypedDict, total=False):
752752
to_upper: bool
753753
regex_engine: Literal['rust-regex', 'python-re'] # default: 'rust-regex'
754754
strict: bool
755+
coerce_numbers_to_str: bool
755756
ref: str
756757
metadata: Any
757758
serialization: SerSchema

src/validators/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ impl StrConstrainedValidator {
208208
|| self.strip_whitespace
209209
|| self.to_lower
210210
|| self.to_upper
211+
|| self.coerce_numbers_to_str
211212
}
212213
}
213214

0 commit comments

Comments
 (0)