from pydantic import BaseSettings, validator
from pathlib import Path


class Config(BaseSettings):
    """Points system configuration."""

    POINTS_DB_FILE: str = "data/danding_points/points.db"
    POINTS_MAX_BALANCE: int = 0  # 0 = unlimited
    POINTS_MAX_PER_OPERATION: int = 0  # 0 = unlimited
    POINTS_LOG_RETENTION_DAYS: int = 365

    class Config:
        env_prefix = "DANDING_"
        case_sensitive = True

    @validator("POINTS_MAX_BALANCE", "POINTS_MAX_PER_OPERATION", "POINTS_LOG_RETENTION_DAYS")
    def validate_non_negative(cls, v):
        if v < 0:
            raise ValueError("Value must be non-negative")
        return v

    @validator("POINTS_DB_FILE")
    def validate_db_path(cls, v):
        if not v:
            raise ValueError("Database file path cannot be empty")
        return v
