Files
wedding-site/server/backend/schema/pydantic.py
MH.Dmitrii a763e9c2e0
Some checks failed
Build Docker / build (push) Has been cancelled
first commit
2026-02-28 10:47:42 +03:00

48 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pydantic import BaseModel, Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
from pydantic.types import StringConstraints
from typing_extensions import Annotated
import re
NameStr = Annotated[
str,
StringConstraints(
min_length=2,
max_length=50,
pattern=r'^[A-Za-zА-ЯЁа-яё]+$'
)
]
class UserAccess(BaseModel):
code:str = Field(...,min_length=6,max_length=6, description="Code of the guest")
class Token(BaseModel):
access_token: str
token_type: str
class UserOut(BaseModel):
name: NameStr = Field(..., description="Name of the guest")
surname: NameStr = Field(..., description="Surname of the guest")
class UserCreate(UserAccess):
pass
class UserUpdate(UserAccess):
name: NameStr = Field(..., description="Name of the guest")
surname: NameStr = Field(..., description="Surname of the guest")
text_field: str = Field("", max_length=500, description="what the guest wants")
activated: bool = Field(False, description="activation of the guest")
food: bool = Field(False, description="Options meat or fish")
alco: bool = Field(False, description="if the guest will drink alco or not")
types_of_alco: str = Field("", description="types of alco")
class Settings(BaseSettings):
DIR:str
PORT:int
SECRET_KEY:str
ALGORITHM:str
ACCESS_TOKEN_EXPIRE_SECONDS:int
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8"
)
settings = Settings()