archive-backend/schemas/user_schema.py
2026-11-07 11:40:36 +00:00

27 lines
609 B
Python

from pydantic import BaseModel, Field, model_validator
class UserCreate(BaseModel):
username: str = Field(min_length=3, max_length=128)
password: str = Field(min_length=6, max_length=128)
password_confirm: str
@model_validator(mode="after")
def passwords_match(self):
if self.password != self.password_confirm:
raise ValueError("Passwords do not match")
return self
class UserRead(BaseModel):
id: int
username: str
isAdmin: bool
class Config:
from_attributes = True
class UserLogin(BaseModel):
username: str
password: str