"""Input validators for the bot."""

import re
from datetime import datetime


def validate_phone_number(phone: str) -> bool:
    """Validate Iranian phone number format."""
    # Iranian phone format: 09XXXXXXXXX or +989XXXXXXXXX
    pattern = r"^(\+98|0)?9\d{9}$"
    return bool(re.match(pattern, phone.replace(" ", "").replace("-", "")))


def validate_full_name(name: str) -> bool:
    """Validate full name - at least 2 words, each word at least 2 characters."""
    if not name or not name.strip():
        return False

    words = name.strip().split()
    if len(words) < 2:
        return False

    return all(len(word) >= 2 for word in words)


def validate_score(score: str) -> bool:
    """Validate score input - non-negative integer."""
    try:
        value = int(score)
        return value >= 0
    except (ValueError, TypeError):
        return False


def validate_datetime(datetime_str: str) -> bool:
    """Validate datetime format YYYY-MM-DD HH:MM."""
    try:
        datetime.strptime(datetime_str, "%Y-%m-%d %H:%M")
        return True
    except ValueError:
        return False