feat: Validate recurrence date before updating RecursNext

This commit is contained in:
Erik Winter (aider) 2024-12-02 08:07:45 +01:00
parent 08f4328580
commit e0a7fb48b9
1 changed files with 5 additions and 0 deletions

View File

@ -150,6 +150,11 @@ func (p *Postgres) RecursNext(id string, date time.Time) error {
return ErrNotARecurrer
}
// Verify that the new date is actually a valid recurrence
if !recurrer.On(date) {
return fmt.Errorf("%w: date %v is not a valid recurrence", ErrPostgresFailure, date)
}
_, err = p.db.Exec(`
UPDATE items
SET recur_next = $1