@@ -96,6 +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 ,
99100 ) -> Any :
100101 """
101102 Validate a Python object against the schema and return the validated object.
@@ -110,6 +111,8 @@ class SchemaValidator:
110111 [`info.context`][pydantic_core.core_schema.ValidationInfo.context].
111112 self_instance: An instance of a model set attributes on from validation, this is used when running
112113 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.
113116
114117 Raises:
115118 ValidationError: If validation fails.
@@ -143,6 +146,7 @@ class SchemaValidator:
143146 strict : bool | None = None ,
144147 context : Any | None = None ,
145148 self_instance : Any | None = None ,
149+ allow_partial : bool = False ,
146150 ) -> Any :
147151 """
148152 Validate JSON data directly against the schema and return the validated Python object.
@@ -160,6 +164,8 @@ class SchemaValidator:
160164 context: The context to use for validation, this is passed to functional validators as
161165 [`info.context`][pydantic_core.core_schema.ValidationInfo.context].
162166 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.
163169
164170 Raises:
165171 ValidationError: If validation fails or if the JSON data is invalid.
@@ -168,7 +174,14 @@ class SchemaValidator:
168174 Returns:
169175 The validated Python object.
170176 """
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 :
172185 """
173186 Validate a string against the schema and return the validated Python object.
174187
@@ -181,6 +194,8 @@ class SchemaValidator:
181194 If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
182195 context: The context to use for validation, this is passed to functional validators as
183196 [`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.
184199
185200 Raises:
186201 ValidationError: If validation fails or if the JSON data is invalid.
0 commit comments