summaryrefslogtreecommitdiff
path: root/app/schemas/user.py
blob: 83a32458d814f4a3c72792bb0780c364630136dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from typing import Optional

from pydantic import BaseModel, EmailStr, Field

from app.schemas.profile import ProfileRead

from .integrations import UserIntegrationRead


class UserCreate(BaseModel):
    username: str = Field(..., max_length=32)
    email: EmailStr
    password: str = Field(..., min_length=8)

    model_config = {
        "extra": "forbid",
    }


class UserRead(BaseModel):
    id: int
    username: str
    email: EmailStr = None
    google_id: Optional[str] = None
    avatar_file: Optional[str] = None
    banner_file: Optional[str] = None
    premium: bool
    is_banned: bool
    is_moderator: bool
    profile: Optional[ProfileRead] = None
    integrations: Optional[UserIntegrationRead] = None
    model_config = {
        "from_attributes": True,
    }