feat(validators): add Check protocol and 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:
31
src/veritext/validators/base.py
Normal file
31
src/veritext/validators/base.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
"""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:
|
||||||
|
"""Return the name of this check."""
|
||||||
|
...
|
||||||
|
|
||||||
|
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.
|
||||||
|
"""
|
||||||
|
...
|
||||||
Reference in New Issue
Block a user