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()