From 7f559571f5f3fb51fb036bbb8e4767a0a4982d69 Mon Sep 17 00:00:00 2001 From: Josue Santana Date: Sat, 22 Jun 2024 06:47:27 -0400 Subject: [PATCH] Fixed broken validator. --- server/models/check_in.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/models/check_in.py b/server/models/check_in.py index 6f2a407f..9482fcaf 100644 --- a/server/models/check_in.py +++ b/server/models/check_in.py @@ -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): @@ -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") @@ -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")