@@ -96,7 +96,7 @@ class SchemaValidator:
9696 from_attributes : bool | None = None ,
9797 context : Any | None = None ,
9898 self_instance : Any | None = None ,
99- allow_partial : bool = False ,
99+ allow_partial : bool | Literal [ 'off' , 'on' , 'trailing-strings' ] = False ,
100100 ) -> Any :
101101 """
102102 Validate a Python object against the schema and return the validated object.
@@ -113,6 +113,7 @@ class SchemaValidator:
113113 validation from the `__init__` method of a model.
114114 allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
115115 and mappings are ignored.
116+ `'trailing-strings'` means any final unfinished JSON string is included in the result.
116117
117118 Raises:
118119 ValidationError: If validation fails.
@@ -146,7 +147,7 @@ class SchemaValidator:
146147 strict : bool | None = None ,
147148 context : Any | None = None ,
148149 self_instance : Any | None = None ,
149- allow_partial : bool = False ,
150+ allow_partial : bool | Literal [ 'off' , 'on' , 'trailing-strings' ] = False ,
150151 ) -> Any :
151152 """
152153 Validate JSON data directly against the schema and return the validated Python object.
@@ -166,6 +167,7 @@ class SchemaValidator:
166167 self_instance: An instance of a model set attributes on from validation.
167168 allow_partial: Whether to allow partial validation; if `True` incomplete JSON will be parsed successfully
168169 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.
169171
170172 Raises:
171173 ValidationError: If validation fails or if the JSON data is invalid.
@@ -180,7 +182,7 @@ class SchemaValidator:
180182 * ,
181183 strict : bool | None = None ,
182184 context : Any | None = None ,
183- allow_partial : bool = False ,
185+ allow_partial : bool | Literal [ 'off' , 'on' , 'trailing-strings' ] = False ,
184186 ) -> Any :
185187 """
186188 Validate a string against the schema and return the validated Python object.
@@ -196,6 +198,7 @@ class SchemaValidator:
196198 [`info.context`][pydantic_core.core_schema.ValidationInfo.context].
197199 allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
198200 and mappings are ignored.
201+ `'trailing-strings'` means any final unfinished JSON string is included in the result.
199202
200203 Raises:
201204 ValidationError: If validation fails or if the JSON data is invalid.
@@ -433,6 +436,7 @@ def from_json(
433436 `all/True` means cache all strings, `keys` means cache only dict keys, `none/False` means no caching.
434437 allow_partial: Whether to allow partial deserialization, if `True` JSON data is returned if the end of the
435438 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.
436440
437441 Raises:
438442 ValueError: If deserialization fails.
0 commit comments