18 lines
469 B
Python
18 lines
469 B
Python
from typing import Protocol, runtime_checkable
|
|
|
|
|
|
@runtime_checkable
|
|
class DataValidatorProtocol(Protocol):
|
|
def validate(self, node, data, context) -> dict: ...
|
|
|
|
|
|
class DataValidatorRegistry:
|
|
_validators: dict[str, DataValidatorProtocol] = {}
|
|
|
|
@classmethod
|
|
def register(cls, workflow_slug, validator):
|
|
cls._validators[workflow_slug] = validator
|
|
|
|
@classmethod
|
|
def get(cls, workflow_slug):
|
|
return cls._validators.get(workflow_slug)
|