feat: Validate recurrence date before updating RecursNext
This commit is contained in:
parent
08f4328580
commit
e0a7fb48b9
|
@ -150,6 +150,11 @@ func (p *Postgres) RecursNext(id string, date time.Time) error {
|
||||||
return ErrNotARecurrer
|
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(`
|
_, err = p.db.Exec(`
|
||||||
UPDATE items
|
UPDATE items
|
||||||
SET recur_next = $1
|
SET recur_next = $1
|
||||||
|
|
Loading…
Reference in New Issue