File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,14 @@ def validate(
1515 * args : Any ,
1616 ** kwargs : Any
1717) -> None :
18+ """
19+ Validate an instance against a given schema using the specified validator class.
20+ """
1821 schema_dict = cast (dict [str , Any ], schema )
1922 cls .check_schema (schema_dict )
2023 validator = cls (schema_dict , * args , ** kwargs )
21- errors = list ( validator . evolve ( schema = schema_dict ). iter_errors ( instance ))
22- if errors :
23- error = best_match ( errors )
24- error . message = f"Validation failed: { error . message } "
24+ error = best_match (
25+ validator . evolve ( schema = schema_dict ). iter_errors ( instance )
26+ )
27+ if error is not None :
2528 raise error
Original file line number Diff line number Diff line change 11from typing import Any
22from typing import cast
3+
34from jsonschema import _keywords
45from jsonschema import _legacy_keywords
56from jsonschema .validators import Draft202012Validator
Original file line number Diff line number Diff line change 11import pytest
2+
23from openapi_schema_validator import validate
34
45
You can’t perform that action at this time.
0 commit comments