38 lines
740 B
Python
38 lines
740 B
Python
# retoor <retoor@molodetz.nl>
|
|||
|
|
from typing import Any
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict
|
||
|
|
|
||
|
|
|
||
|
|
class OutModel(BaseModel):
|
||
|
|
model_config = ConfigDict(extra="ignore", from_attributes=True)
|
||
|
|
|
||
|
|
|
||
|
|
class ActionResult(OutModel):
|
||
|
|
ok: bool = True
|
||
|
|
redirect: str | None = None
|
||
|
|
data: Any = None
|
||
|
|
|
||
|
|
|
||
|
|
class ErrorBody(OutModel):
|
||
|
|
status: int = 500
|
||
|
|
message: str = ""
|
||
|
|
|
||
|
|
|
||
|
|
class ErrorOut(OutModel):
|
||
|
|
error: ErrorBody = ErrorBody()
|
||
|
|
|
||
|
|
|
||
|
|
class ValidationErrorOut(OutModel):
|
||
|
|
error: str = "validation"
|
||
|
|
fields: list[str] = []
|
||
|
|
messages: list[str] = []
|
||
|
|
|
||
|
|
|
||
|
|
class PublicUserOut(OutModel):
|
||
|
|
uid: str | None = None
|
||
|
|
username: str | None = None
|
||
|
|
role: str | None = None
|
||
|
|
bio: str | None = None
|
||
|
|
created_at: str | None = None
|