Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flavien-hugs committed Sep 15, 2024
1 parent b6cf28a commit ed0b11d
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/schemas/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
from typing import Any, Dict, Optional

from beanie import PydanticObjectId
from pydantic import BaseModel, EmailStr, Field, StrictStr, field_validator, model_validator
from starlette import status

from src.common.helpers.exceptions import CustomHTTException
from src.config import settings
from src.shared.error_codes import AuthErrorCode
from pydantic import BaseModel, EmailStr, Field, field_validator, StrictStr


class PhonenumberModel(BaseModel):
Expand All @@ -23,18 +18,6 @@ def phonenumber_validation(cls, value): # noqa: B902
class SignupBaseModel(PhonenumberModel):
password: Optional[str] = None

@model_validator(mode="before")
@classmethod
def validate_password(cls, values: dict):
password = values.get("password")
if len(password) > settings.PASSWORD_MIN_LENGTH:
return values
raise CustomHTTException(
code_error=AuthErrorCode.AUTH_PASSWORD_MISMATCH,
message_error="The password must be 6 characters or more.",
status_code=status.HTTP_400_BAD_REQUEST,
)


class UserBaseSchema(SignupBaseModel):
fullname: Optional[StrictStr] = Field(default=None, examples=["John Doe"])
Expand Down

0 comments on commit ed0b11d

Please sign in to comment.