from .constants import NUTRITION_LEVELS
from .exceptions import InvalidNutritionLevelError


def validate_nutrition_level(level):
    if not isinstance(level, str):
        raise InvalidNutritionLevelError("Nutrition level must be a string.")
    normalized = level.strip().upper()
    if normalized not in NUTRITION_LEVELS:
        raise InvalidNutritionLevelError(
            f"Nutrition level must be one of: {', '.join(NUTRITION_LEVELS)}."
        )
    return normalized
