add password validation example
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
from pydantic import BaseModel, EmailStr, ConfigDict
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BaseModel, EmailStr, ConfigDict, BeforeValidator
|
||||
|
||||
from src.schemas.validators import ensure_password
|
||||
|
||||
|
||||
class User(BaseModel):
|
||||
@@ -16,4 +20,4 @@ class UserWithHashedPass(User):
|
||||
class UserRequest(BaseModel):
|
||||
username: str
|
||||
email: EmailStr | None = None
|
||||
password: str
|
||||
password: Annotated[str, BeforeValidator(ensure_password)]
|
||||
|
||||
6
src/schemas/validators.py
Normal file
6
src/schemas/validators.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
|
||||
def ensure_password(value: Any) -> Any:
|
||||
#TODO
|
||||
...
|
||||
Reference in New Issue
Block a user