Fix email validation dependency issue
- Added email-validator package to requirements.txt - Modified user schema to provide fallback if email-validator is not available - This fixes the health check failure due to missing email-validator dependency
This commit is contained in:
parent
fec0fa72e7
commit
b3cbb43878
@ -1,7 +1,24 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
# Try to import EmailStr from pydantic, and provide a fallback if email-validator is not available
|
||||
try:
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
except ImportError:
|
||||
from pydantic import BaseModel, Field
|
||||
# Define a basic EmailStr replacement that accepts strings but doesn't validate them
|
||||
# This will be used only if email-validator is not installed
|
||||
from pydantic.types import StringType
|
||||
class EmailStr(StringType):
|
||||
@classmethod
|
||||
def __get_validators__(cls):
|
||||
yield cls.validate
|
||||
|
||||
@classmethod
|
||||
def validate(cls, v):
|
||||
if not isinstance(v, str):
|
||||
raise ValueError('string required')
|
||||
return v
|
||||
|
||||
|
||||
class UserBase(BaseModel):
|
||||
|
@ -2,6 +2,7 @@ fastapi>=0.95.0
|
||||
uvicorn>=0.21.1
|
||||
pydantic>=2.0.0
|
||||
pydantic-settings>=2.0.0
|
||||
email-validator>=2.0.0
|
||||
python-dotenv>=1.0.0
|
||||
sqlalchemy>=2.0.0
|
||||
alembic>=1.10.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user