from fastapi import Request
from typing import List, Optional


class AddArtistForm:
    def __init__(self, request: Request, artist_id: str, artist_name: str, artist_link: str):
        self.request = request
        self.errors: List = []
        self.id: str = artist_id
        self.name: Optional[str] = artist_name
        self.link: Optional[str] = artist_link


    async def load_data(self):
        form = await self.request.form()
        print(f"{form.keys()}")
        self.name = form.get("artist.name")
        self.link = form.get("artist.link")

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

    def __str__(self):
        return f"{self.name=}, {self.link=}"
