```
Switch to timezone.utc for event date validation
Replaced ZoneInfo('UTC') with timezone.utc in event date validation to ensure consistency and compatibility with standard libraries. Simplifies datetime handling and avoids potential issues with external dependencies.
```
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime, time
|
||||
from datetime import datetime, time, timezone
|
||||
from typing import Dict, Optional, List, Union
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
@@ -39,7 +39,7 @@ class EventBase(BaseModel):
|
||||
|
||||
@field_validator('event_date')
|
||||
def validate_event_date(cls, v):
|
||||
if v < datetime.now(ZoneInfo('UTC')):
|
||||
if v < datetime.now(tz=timezone.utc):
|
||||
raise ValueError("Event date cannot be in the past")
|
||||
return v
|
||||
|
||||
|
||||
Reference in New Issue
Block a user