Skip to main content

PydanticPluginProtocol

Protocol defining the interface for Pydantic plugins.

Methods


new_schema_validator()

@classmethod
def new_schema_validator(
schema: CoreSchema,
schema_type: Any,
schema_type_path: [SchemaTypePath](schematypepath.md?sid=pydantic_plugin_schematypepath),
schema_kind: SchemaKind,
config: CoreConfig | None,
plugin_settings: dict[str, object]
) - > tuple[ValidatePythonHandlerProtocol | None, ValidateJsonHandlerProtocol | None, ValidateStringsHandlerProtocol | None]

This method is called for each plugin every time a new [SchemaValidator][pydantic_core.SchemaValidator] is created. It should return an event handler for each of the three validation methods, or None if the plugin does not implement that method.

Parameters

NameTypeDescription
schemaCoreSchemaThe schema to validate against.
schema_typeAnyThe original type which the schema was created from, e.g. the model class.
schema_type_path[SchemaTypePath](schematypepath.md?sid=pydantic_plugin_schematypepath)Path defining where schema_type was defined, or where TypeAdapter was called.
schema_kindSchemaKindThe kind of schema to validate against.
config`CoreConfigNone`
plugin_settingsdict[str, object]Any plugin settings.

Returns

TypeDescription
`tuple[ValidatePythonHandlerProtocolNone, ValidateJsonHandlerProtocol