Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Add date format validation for changelog entries - Validate YYYY-MM-DD format in schema and runtime - Throws clear error on malformed dates
Sushmithamallesh committed
Jan 4, 2026 at 22:38 UTC
c28beba4f338f0ac97c706e30afb5688875f248e
2 files changed
+15
-1
fumadocs/lib/source.ts
+12
@@ -71,14 +71,26 @@ export function formatDate(dateStr: string): string {
71
});
72
}
73
74
+const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
75
+
76
+function validateDateFormat(dateStr: string): void {
77
+ if (!DATE_REGEX.test(dateStr)) {
78
+ throw new Error(
79
+ `Invalid date format: "${dateStr}". Expected YYYY-MM-DD (e.g., "2025-12-29")`
80
+ );
81
+ }
82
+}
83
+
84
export function dateToChangelogUrl(dateStr: string): string {
85
// Convert "2025-12-29" to "/docs/changelog/2025/12/29"
86
+ validateDateFormat(dateStr);
87
const [year, month, day] = dateStr.split('-');
88
return `/docs/changelog/${year}/${month}/${day}`;
89
}
90
91
export function dateToSlug(dateStr: string): string[] {
92
// Convert "2025-12-29" to ["2025", "12", "29"]
93
+ validateDateFormat(dateStr);
94
const [year, month, day] = dateStr.split('-');
95
return [year, month, day];
96
}
fumadocs/source.config.ts
+3
-1
@@ -72,7 +72,9 @@ export const changelog = defineCollections({
72
type: 'doc',
73
dir: 'content/changelog',
74
schema: frontmatterSchema.extend({
75
- date: z.string(),
75
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, {
76
+ message: 'Date must be in YYYY-MM-DD format (e.g., "2025-12-29")',
77
+ }),
78
}),
79
});
80