fix(tasks): refuse a cycle start that is not a real date

A corrupt import is stored as it came, and "2026-13-01" passed the
pattern, then threw in periodOf on every render. "2026-02-30" rolled into
March instead and moved the cycle. The schema now round-trips the date,
so either is kept on disk and left off screen like any unreadable task.
Found by the schema-guardian review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-16 05:37:36 +02:00
1 parent 2477b0a8a7
commit 8d0b45f83a
2 files changed
+19 -1

No files matched your search

+7
View File
@@ -124,4 +124,11 @@ describe("periodOf: cycles", () => {
expect(PeriodSchema.safeParse(cycle(367, "2026-01-01")).success).toBe(false);
expect(PeriodSchema.safeParse(cycle(14, "16 Oct")).success).toBe(false);
});
test("a start that is not a real date is refused, not rolled over or thrown on later", () => {
// A corrupt import is stored verbatim; the schema is what keeps it off screen.
expect(PeriodSchema.safeParse(cycle(14, "2026-13-01")).success).toBe(false);
expect(PeriodSchema.safeParse(cycle(14, "2026-02-30")).success).toBe(false);
expect(PeriodSchema.safeParse(cycle(14, "2028-02-29")).success).toBe(true);
});
});