Source code for structum_lab.validation
# src/structum_lab/validation.py
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 PythonWoods
"""
Core Validation Interfaces.
This module defines the protocols for system validation.
Plugins can implement `Validator` to participate in the bootstrap process
without depending directly on the `structum-bootstrap` package.
"""
from typing import Protocol, Any, Dict, List, Optional
[docs]
class ValidationContext(Protocol):
"""Context object passed to validators to collect results."""
[docs]
def add_check(self, name: str, passed: bool, message: str = "") -> None:
"""Record the result of a specific check."""
...
[docs]
def add_warning(self, message: str) -> None:
"""Record a non-fatal warning."""
...
[docs]
def is_valid(self) -> bool:
"""Returns True if all checks passed so far."""
...
[docs]
class Validator(Protocol):
"""Protocol for any component that can perform validation."""
[docs]
def validate(self, context: ValidationContext) -> None:
"""
Execute validation logic and update the context.
Args:
context: The bootstrap context to record success/failure/warnings.
"""
...