Validation utilities for pyetm curve and export types.
This module provides validation functionsthat raise clear ValueError exceptions
when invalid curve types, carrier types, or export names are provided.
Functions
validate_carrier_type
validate_carrier_type(carrier_type)
Validate that carrier_type is a valid carrier type.
Source code in src/pyetm/validators.py
| def validate_carrier_type(carrier_type: str) -> str:
"""Validate that carrier_type is a valid carrier type."""
return cast(
str,
_validate_literal_type(carrier_type, CarrierType, "carrier type", singular=True),
)
|
validate_export_names
validate_export_names(export_names)
Validate and normalize export names.
Source code in src/pyetm/validators.py
| def validate_export_names(export_names: str | list[str]) -> list[str]:
"""Validate and normalize export names."""
return cast(
list[str], _validate_literal_type(export_names, AnnualExportType, "export names")
)
|
validate_hourly_curve_names
validate_hourly_curve_names(curve_names)
Validate and normalize hourly curve names.
Legacy engine names (e.g. merit_order, heat_network) are accepted and normalized.
Source code in src/pyetm/validators.py
| def validate_hourly_curve_names(curve_names: str | list[str]) -> list[str]:
"""Validate and normalize hourly curve names.
Legacy engine names (e.g. ``merit_order``, ``heat_network``) are accepted and normalized.
"""
from pyetm.config import curve_registry as registry
names = [curve_names] if isinstance(curve_names, str) else curve_names
canonical = [registry.accept_alias(name) for name in names]
return cast(
list[str], _validate_literal_type(canonical, HourlyCurveType, "curve names")
)
|