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

1""" 

2Type definitions for CSV field validation. 

3 

4This module provides type aliases and protocols for better type safety 

5and code documentation in the field validation package. 

6""" 

7from __future__ import annotations 

8 

9from typing import Any, Protocol 

10 

11# Type aliases for better readability 

12ErrorDict = dict[str, Any] 

13FieldDict = dict[str, Any] 

14RowData = list[str] 

15HeaderData = list[str] 

16 

17 

18class ValidationProtocol(Protocol): 

19 """Protocol for validation functions.""" 

20 

21 def __call__(self, value: str, **kwargs: Any) -> ErrorDict | None: 

22 """Validate a value and return error dict if invalid, None if valid.""" 

23 ... 

24 

25 

26# Constants for supported field types 

27SUPPORTED_FIELD_TYPES = frozenset({"string", "number", "integer", "boolean"}) 

28NUMERIC_FIELD_TYPES = frozenset({"number", "integer"})