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
| Attribute | Type | Description |
|---|---|---|
| type | Literal['is-subclass'] | A required literal identifier used to distinguish this schema as an 'is-subclass' validator. |
| cls | type[Any] | The required Python class that the input value must be a subclass of. |
| cls_repr | str | A custom string representation of the target class used in error messages and schema exports. |
| ref | str | A unique string identifier used for recursive schema references and internal lookups. |
| metadata | dict[str, Any] | A dictionary of additional configuration data or custom annotations for the schema. |
| serialization | SerSchema | Custom 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
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
str | The 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
| Type | Description |
|---|---|
str | The 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
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
SerSchema | The serialization schema configuration defining how to transform the class to a serializable format. |