Skip to content

Commit

Permalink
Fixed broken validator.
Browse files Browse the repository at this point in the history
  • Loading branch information
janthonysantana committed Jun 22, 2024
1 parent 709c85f commit 7f55957
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/models/check_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from datetime import datetime, timedelta
from pydantic import BaseModel, Field, constr, field_validator
from pydantic import BaseModel, Field, field_validator, validator
from enum import Enum

class Frequency(str, Enum):
Expand Down Expand Up @@ -31,7 +31,7 @@ def save(self, db):
document = self.dict()
db.check_ins.insert_one(document)

@field_validator('check_in_time', pre=True)
@field_validator('check_in_time', mode='before')
def check_future_date(cls, v):
if v < datetime.now():
raise ValueError("Check-in time must be in the future")
Expand Down Expand Up @@ -68,7 +68,7 @@ def validate_check_in_time(db, user_id, proposed_time):
return True # No conflicts found

# Validator to ensure reminder times are valid
@validator('reminder_times', each_item=True, pre=True)
@validator('reminder_times', each_item=True, mode='True')
def validate_reminder_times(cls, v):
if v.total_seconds() not in [3600, 86400, 604800, 2592000]: # 1 hour, 1 day, 1 week, ~1 month
raise ValueError("Invalid reminder time")
Expand Down

0 comments on commit 7f55957

Please sign in to comment.