File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -200,15 +200,14 @@ impl StrConstrainedValidator {
200200 }
201201
202202 // whether any of the constraints/customisations are actually enabled
203- // except strict which can be set on StrValidator
203+ // except strict and coerce_numbers_to_str which can be set on StrValidator
204204 fn has_constraints_set ( & self ) -> bool {
205205 self . pattern . is_some ( )
206206 || self . max_length . is_some ( )
207207 || self . min_length . is_some ( )
208208 || self . strip_whitespace
209209 || self . to_lower
210210 || self . to_upper
211- || self . coerce_numbers_to_str
212211 }
213212}
214213
Original file line number Diff line number Diff line change @@ -286,6 +286,14 @@ class StrSubclass(str):
286286 assert not isinstance (v .validate_python (StrSubclass ('' ), strict = True ), StrSubclass )
287287
288288
289+ @pytest .mark .parametrize ('string' , [True , False ])
290+ def test_coerce_numbers_to_str_with_invalid_unicode_character (string ) -> None :
291+ config = core_schema .CoreConfig (coerce_numbers_to_str = True )
292+
293+ v = SchemaValidator (core_schema .str_schema (strict = string ), config )
294+ assert v .validate_python ('\ud835 ' ) == '\ud835 '
295+
296+
289297def test_coerce_numbers_to_str_disabled_in_strict_mode () -> None :
290298 config = core_schema .CoreConfig (coerce_numbers_to_str = True )
291299
You can’t perform that action at this time.
0 commit comments