from fastapi import Request
from typing import List, Optional


class ValidateComicForm:
    def __init__(self, request: Request, comic_id: str, completed: bool, current_order: bool):
        self.request = request
        self.errors: List = []
        self.id = comic_id
        self.title: Optional[str] = None
        self.weblink: Optional[str] = None
        self.completed = completed
        self.current_order = current_order

    async def load_data(self):
        form = await self.request.form()
        print(f"{form.keys()}")
        self.title = form.get("title")
        self.weblink = form.get("weblink")

    def is_valid(self):
        if not self.errors:
            return True
        return False

    def __str__(self):
        return f"{self.title=}, {self.weblink=}"
