@@ -96,7 +96,7 @@ class SchemaValidator:
96
96
from_attributes : bool | None = None ,
97
97
context : Any | None = None ,
98
98
self_instance : Any | None = None ,
99
- allow_partial : bool = False ,
99
+ allow_partial : bool | Literal [ 'off' , 'on' , 'trailing-strings' ] = False ,
100
100
) -> Any :
101
101
"""
102
102
Validate a Python object against the schema and return the validated object.
@@ -113,6 +113,7 @@ class SchemaValidator:
113
113
validation from the `__init__` method of a model.
114
114
allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
115
115
and mappings are ignored.
116
+ `'trailing-strings'` means any final unfinished JSON string is included in the result.
116
117
117
118
Raises:
118
119
ValidationError: If validation fails.
@@ -146,7 +147,7 @@ class SchemaValidator:
146
147
strict : bool | None = None ,
147
148
context : Any | None = None ,
148
149
self_instance : Any | None = None ,
149
- allow_partial : bool = False ,
150
+ allow_partial : bool | Literal [ 'off' , 'on' , 'trailing-strings' ] = False ,
150
151
) -> Any :
151
152
"""
152
153
Validate JSON data directly against the schema and return the validated Python object.
@@ -166,6 +167,7 @@ class SchemaValidator:
166
167
self_instance: An instance of a model set attributes on from validation.
167
168
allow_partial: Whether to allow partial validation; if `True` incomplete JSON will be parsed successfully
168
169
and errors in the last element of sequences and mappings are ignored.
170
+ `'trailing-strings'` means any final unfinished JSON string is included in the result.
169
171
170
172
Raises:
171
173
ValidationError: If validation fails or if the JSON data is invalid.
@@ -180,7 +182,7 @@ class SchemaValidator:
180
182
* ,
181
183
strict : bool | None = None ,
182
184
context : Any | None = None ,
183
- allow_partial : bool = False ,
185
+ allow_partial : bool | Literal [ 'off' , 'on' , 'trailing-strings' ] = False ,
184
186
) -> Any :
185
187
"""
186
188
Validate a string against the schema and return the validated Python object.
@@ -196,6 +198,7 @@ class SchemaValidator:
196
198
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
197
199
allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
198
200
and mappings are ignored.
201
+ `'trailing-strings'` means any final unfinished JSON string is included in the result.
199
202
200
203
Raises:
201
204
ValidationError: If validation fails or if the JSON data is invalid.
@@ -433,6 +436,7 @@ def from_json(
433
436
`all/True` means cache all strings, `keys` means cache only dict keys, `none/False` means no caching.
434
437
allow_partial: Whether to allow partial deserialization, if `True` JSON data is returned if the end of the
435
438
input is reached before the full object is deserialized, e.g. `["aa", "bb", "c` would return `['aa', 'bb']`.
439
+ `'trailing-strings'` means any final unfinished JSON string is included in the result.
436
440
437
441
Raises:
438
442
ValueError: If deserialization fails.
0 commit comments