Coverage for src/csv_schema_validator/field_validators/types.py: 100%
10 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-23 15:34 +0100
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-23 15:34 +0100
1"""
2Type definitions for CSV field validation.
4This module provides type aliases and protocols for better type safety
5and code documentation in the field validation package.
6"""
7from __future__ import annotations
9from typing import Any, Protocol
11# Type aliases for better readability
12ErrorDict = dict[str, Any]
13FieldDict = dict[str, Any]
14RowData = list[str]
15HeaderData = list[str]
18class ValidationProtocol(Protocol):
19 """Protocol for validation functions."""
21 def __call__(self, value: str, **kwargs: Any) -> ErrorDict | None:
22 """Validate a value and return error dict if invalid, None if valid."""
23 ...
26# Constants for supported field types
27SUPPORTED_FIELD_TYPES = frozenset({"string", "number", "integer", "boolean"})
28NUMERIC_FIELD_TYPES = frozenset({"number", "integer"})