Skip to content

hololinked.core.interfaces.schema_validators.BaseSchemaValidator

Base class for all schema validators.

Serves as a type definition.

Source code in repo/hololinked/hololinked/core/interfaces/schema_validators.py
class BaseSchemaValidator:
    """
    Base class for all schema validators.

    Serves as a type definition.
    """

    def __init__(self, schema) -> None:
        self.schema = schema

    def validate(self, data: Any) -> None:
        """Validate the data against the schema."""
        raise NotImplementedError("validate method must be implemented by subclass")

    def validate_method_call(self, args: tuple[Any], kwargs: dict[str, Any]) -> None:
        """Validate the method call against the schema."""
        raise NotImplementedError("validate_method_call method must be implemented by subclass")

    def json(self) -> JSONSchemaType:
        """Allows JSON serialization of the validator instance itself."""
        raise NotImplementedError("json method must be implemented by subclass")

    def __get_state__(self) -> JSONSchemaType:
        return self.json()

    def __set_state__(self, schema: JSONSchemaType):
        raise NotImplementedError("__set_state__ method must be implemented by subclass")

Attributes

schema instance-attribute

schema = schema

Functions

__init__

__init__(schema) -> None
Source code in repo/hololinked/hololinked/core/interfaces/schema_validators.py
def __init__(self, schema) -> None:
    self.schema = schema

json

json() -> JSONSchemaType

Allows JSON serialization of the validator instance itself.

Source code in repo/hololinked/hololinked/core/interfaces/schema_validators.py
def json(self) -> JSONSchemaType:
    """Allows JSON serialization of the validator instance itself."""
    raise NotImplementedError("json method must be implemented by subclass")

validate

validate(data: Any) -> None

Validate the data against the schema.

Source code in repo/hololinked/hololinked/core/interfaces/schema_validators.py
def validate(self, data: Any) -> None:
    """Validate the data against the schema."""
    raise NotImplementedError("validate method must be implemented by subclass")

validate_method_call

validate_method_call(args: tuple[Any], kwargs: dict[str, Any]) -> None

Validate the method call against the schema.

Source code in repo/hololinked/hololinked/core/interfaces/schema_validators.py
def validate_method_call(self, args: tuple[Any], kwargs: dict[str, Any]) -> None:
    """Validate the method call against the schema."""
    raise NotImplementedError("validate_method_call method must be implemented by subclass")