Skip to content

attribute_model

Classes:

Name Description
AttributeModel

Classes#

AttributeModel #

Bases: BaseModel

Methods:

Name Description
validate_all_ascii

Functions#

validate_all_ascii #
validate_all_ascii(
    values: Dict[Any, Any]
) -> Dict[str, str]
Source code in tsdat/config/attributes/attribute_model.py
@root_validator(skip_on_failure=True)
def validate_all_ascii(cls, values: Dict[Any, Any]) -> Dict[str, str]:
    for key, value in values.items():
        if not isinstance(key, str) or not key.isascii():
            raise ValueError(f"'{key}' contains a non-ascii character.")
        if isinstance(value, str) and not value.isascii():
            raise ValueError(
                f"attr '{key}' -> '{value}' contains a non-ascii character."
            )
    return values