@@ -96,6 +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
100
) -> Any :
100
101
"""
101
102
Validate a Python object against the schema and return the validated object.
@@ -110,6 +111,8 @@ class SchemaValidator:
110
111
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
111
112
self_instance: An instance of a model set attributes on from validation, this is used when running
112
113
validation from the `__init__` method of a model.
114
+ allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
115
+ and mappings are ignored.
113
116
114
117
Raises:
115
118
ValidationError: If validation fails.
@@ -143,6 +146,7 @@ class SchemaValidator:
143
146
strict : bool | None = None ,
144
147
context : Any | None = None ,
145
148
self_instance : Any | None = None ,
149
+ allow_partial : bool = False ,
146
150
) -> Any :
147
151
"""
148
152
Validate JSON data directly against the schema and return the validated Python object.
@@ -160,6 +164,8 @@ class SchemaValidator:
160
164
context: The context to use for validation, this is passed to functional validators as
161
165
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
162
166
self_instance: An instance of a model set attributes on from validation.
167
+ allow_partial: Whether to allow partial validation; if `True` incomplete JSON will be parsed successfully
168
+ and errors in the last element of sequences and mappings are ignored.
163
169
164
170
Raises:
165
171
ValidationError: If validation fails or if the JSON data is invalid.
@@ -168,7 +174,14 @@ class SchemaValidator:
168
174
Returns:
169
175
The validated Python object.
170
176
"""
171
- def validate_strings (self , input : _StringInput , * , strict : bool | None = None , context : Any | None = None ) -> Any :
177
+ def validate_strings (
178
+ self ,
179
+ input : _StringInput ,
180
+ * ,
181
+ strict : bool | None = None ,
182
+ context : Any | None = None ,
183
+ allow_partial : bool = False ,
184
+ ) -> Any :
172
185
"""
173
186
Validate a string against the schema and return the validated Python object.
174
187
@@ -181,6 +194,8 @@ class SchemaValidator:
181
194
If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
182
195
context: The context to use for validation, this is passed to functional validators as
183
196
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
197
+ allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
198
+ and mappings are ignored.
184
199
185
200
Raises:
186
201
ValidationError: If validation fails or if the JSON data is invalid.
0 commit comments