Skip to content

Commit

Permalink
add init validation on recurrence
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Nov 14, 2024
1 parent dac92ae commit 45e21b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dooit/api/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime, timedelta
from typing import List
from sqlalchemy import ForeignKey, select, nulls_last
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy.orm import Mapped, mapped_column, relationship, validates
from .model import DooitModel
from .manager import manager

Expand Down Expand Up @@ -47,6 +47,13 @@ class Todo(DooitModel):
order_by=order_index,
)

@validates("recurrence")
def validate_pending(self, key, value):
if value is not None:
self.pending = True

return value

@classmethod
def from_id(cls, _id: str) -> "Todo":
_id = _id.lstrip("Todo_")
Expand Down

0 comments on commit 45e21b6

Please sign in to comment.