From d17d3de06de74ba3ce8e67320849771dbf77167a Mon Sep 17 00:00:00 2001 From: Kai Chappell Date: Sat, 22 Mar 2025 10:48:29 +0000 Subject: [PATCH] validator protocol + base types Define the Check protocol for validation checks that compute a score and return pass/fail results with diagnostics. --- src/veritext/validators/base.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/veritext/validators/base.py diff --git a/src/veritext/validators/base.py b/src/veritext/validators/base.py new file mode 100644 index 0000000..8001c8a --- /dev/null +++ b/src/veritext/validators/base.py @@ -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. + """ + ...