feat: Addition of authentication and user management systems
This commit is contained in:
27
app/api/v1/schemas/user.py
Normal file
27
app/api/v1/schemas/user.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from pydantic import BaseModel, Field, EmailStr, field_validator
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# User
|
||||
# ----------------------------------------------------------------------
|
||||
class UserCreate(BaseModel):
|
||||
username: str = Field(..., min_length=3, max_length=30)
|
||||
email: EmailStr
|
||||
password: str = Field(..., min_length=8)
|
||||
|
||||
@field_validator("username")
|
||||
def all_allowed_chars(cls, v):
|
||||
for v_char in v:
|
||||
if not v_char in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_":
|
||||
raise ValueError("username can only contain a-z, A-Z, 0-9 and _")
|
||||
return v
|
||||
|
||||
|
||||
class UserRead(BaseModel):
|
||||
id: int
|
||||
username: str
|
||||
email: EmailStr
|
||||
stats: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user