Files
piaps-course-work-university/backend/app/schemas/general.py

28 lines
694 B
Python

from typing import Self
from pydantic import (
BaseModel,
ConfigDict,
EmailStr,
Field, model_validator,
)
from app.auth.utils import get_password_hash
class EmailSchema(BaseModel):
email: EmailStr = Field(description="Электронная почта")
model_config = ConfigDict(from_attributes=True)
class PasswordSchema(BaseModel):
password: str = Field(
min_length=5, max_length=50, description="Пароль, от 5 до 50 знаков"
)
model_config = ConfigDict(from_attributes=True)
@model_validator(mode="after")
def check_password(self) -> Self:
self.password = get_password_hash(self.password)
return self