MCPcopy
hub / github.com/pydantic/pydantic / CustomOnValidateJson

Class CustomOnValidateJson

tests/test_plugins.py:35–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34def test_on_validate_json_on_success() -> None:
35 class CustomOnValidateJson(ValidateJsonHandlerProtocol):
36 def on_enter(
37 self,
38 input: str | bytes | bytearray,
39 *,
40 strict: bool | None = None,
41 extra: ExtraValues | None = None,
42 context: Any | None = None,
43 self_instance: Any | None = None,
44 by_alias: bool | None = None,
45 by_name: bool | None = None,
46 ) -> None:
47 assert input == '{"a": 1}'
48 assert strict is None
49 assert extra is None
50 assert context is None
51 assert self_instance is None
52
53 def on_success(self, result: Any) -> None:
54 assert isinstance(result, Model)
55
56 class CustomPlugin(PydanticPluginProtocol):
57 def new_schema_validator(self, schema, schema_type, schema_type_path, schema_kind, config, plugin_settings):

Callers 2

new_schema_validatorMethod · 0.85
new_schema_validatorMethod · 0.85

Calls

no outgoing calls

Tested by 2

new_schema_validatorMethod · 0.68
new_schema_validatorMethod · 0.68