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 {
200
200
}
201
201
202
202
// 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
204
204
fn has_constraints_set ( & self ) -> bool {
205
205
self . pattern . is_some ( )
206
206
|| self . max_length . is_some ( )
207
207
|| self . min_length . is_some ( )
208
208
|| self . strip_whitespace
209
209
|| self . to_lower
210
210
|| self . to_upper
211
- || self . coerce_numbers_to_str
212
211
}
213
212
}
214
213
Original file line number Diff line number Diff line change @@ -286,6 +286,14 @@ class StrSubclass(str):
286
286
assert not isinstance (v .validate_python (StrSubclass ('' ), strict = True ), StrSubclass )
287
287
288
288
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
+
289
297
def test_coerce_numbers_to_str_disabled_in_strict_mode () -> None :
290
298
config = core_schema .CoreConfig (coerce_numbers_to_str = True )
291
299
You can’t perform that action at this time.
0 commit comments