Skip to content

Commit 7880f0b

Browse files
committed
refactor(validations): add fallback behavior comments
1 parent e15a46a commit 7880f0b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/validations.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const streakParamsSchema = z.object({
2222
// Silently fall back to 'linear' for unknown values (matches old behavior)
2323
scale: z.enum(['linear', 'log']).catch('linear').default('linear'),
2424

25+
// Invalid size values fall back to 'medium' to preserve badge rendering.
2526
size: z.enum(['small', 'medium', 'large']).catch('medium').default('medium'),
2627

2728
// Silently fall back to '8s' for invalid format (matches old behavior)
@@ -30,6 +31,7 @@ export const streakParamsSchema = z.object({
3031
.transform((val) => sanitizeSpeed(val, '8s'))
3132
.default('8s'),
3233

34+
// Invalid radius values are sanitized and fall back to 8px.
3335
radius: z
3436
.string()
3537
.transform((val) => sanitizeRadius(val, 8))
@@ -71,7 +73,9 @@ export const streakParamsSchema = z.object({
7173
.optional()
7274
.transform((val) => val === 'true' || val === '1'),
7375
lang: z.string().optional().default('en'),
76+
// Unknown view values fall back to the default dashboard view.
7477
view: z.enum(['default', 'monthly']).catch('default').default('default'),
78+
// Invalid delta formats fall back to percentage mode.
7579
delta_format: z.enum(['percent', 'absolute', 'both']).catch('percent').default('percent'),
7680
width: z.string().optional(),
7781
height: z.string().optional(),

0 commit comments

Comments
 (0)