Skip to main content

IsSubclassSchema

This class defines the schema for a subclass validation check, ensuring that a given input is a subclass of a specified type. It includes required fields for the schema type and the target class, while providing optional fields for custom class representations, references, and metadata.

Attributes

AttributeTypeDescription
typeLiteral['is-subclass']A required literal identifier used to distinguish this schema as an 'is-subclass' validator.
clstype[Any]The required Python class that the input value must be a subclass of.
cls_reprstrA custom string representation of the target class used in error messages and schema exports.
refstrA unique string identifier used for recursive schema references and internal lookups.
metadatadict[str, Any]A dictionary of additional configuration data or custom annotations for the schema.
serializationSerSchemaCustom serialization configuration that defines how the subclass reference should be handled during export.

Methods


type()

def type() - > Literal['is-subclass']

Identifies the schema type as a subclass check.

Returns

TypeDescription
Literal['is-subclass']A constant string used for schema type discrimination.

cls()

def cls() - > type[Any]

Specifies the target class that the input value must be a subclass of.

Returns

TypeDescription
type[Any]The class type used for the subclass validation check.

cls_repr()

def cls_repr() - > str

Provides an optional custom string representation for the class to be used in error messages or documentation.

Returns

TypeDescription
strThe string representation of the target class.

ref()

def ref() - > str

Defines an optional shared reference identifier for the schema, allowing it to be reused or referenced recursively.

Returns

TypeDescription
strThe unique reference string for this schema definition.

metadata()

def metadata() - > dict[str, Any]

Stores a dictionary of custom metadata that can be used by plugins or third-party tools to extend schema behavior.

Returns

TypeDescription
dict[str, Any]A mapping of arbitrary metadata keys and values.

serialization()

def serialization() - > SerSchema

Configures how the subclass reference should be handled during the serialization process.

Returns

TypeDescription
SerSchemaThe serialization schema configuration defining how to transform the class to a serializable format.