validator protocol + base types

Define the Check protocol for validation checks that compute a score
and return pass/fail results with diagnostics.
This commit is contained in:
2025-03-22 10:48:29 +00:00
parent 9f53446ca7
commit d17d3de06d

View File

@@ -0,0 +1,29 @@
"""Base types and protocols for validation checks."""
from typing import Protocol, runtime_checkable
from veritext.core.types import CheckResult, ValidationContext
@runtime_checkable
class Check(Protocol):
"""Protocol for validation checks.
A Check computes a score or property of text and compares it against
a threshold to produce a pass/fail result.
"""
@property
def name(self) -> str: ...
def check(self, text: str, context: ValidationContext) -> CheckResult:
"""Run the check and return a result.
Args:
text: The text to validate.
context: Validation context containing reference text and metadata.
Returns:
CheckResult with pass/fail status and diagnostics.
"""
...