Skip to content

Commit 39b37f5

Browse files
authored
refactor(validations): add fallback behavior comments (JhaSourav07#757)
2 parents 9add5d6 + 7880f0b commit 39b37f5

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
@@ -28,6 +28,7 @@ export const streakParamsSchema = z.object({
2828
// Silently fall back to 'linear' for unknown values (matches old behavior)
2929
scale: z.enum(['linear', 'log']).catch('linear').default('linear'),
3030

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

3334
// Silently fall back to '8s' for invalid format (matches old behavior)
@@ -36,6 +37,7 @@ export const streakParamsSchema = z.object({
3637
.transform((val) => sanitizeSpeed(val, '8s'))
3738
.default('8s'),
3839

40+
// Invalid radius values are sanitized and fall back to 8px.
3941
radius: z
4042
.string()
4143
.transform((val) => sanitizeRadius(val, 8))
@@ -77,7 +79,9 @@ export const streakParamsSchema = z.object({
7779
.optional()
7880
.transform((val) => val === 'true' || val === '1'),
7981
lang: z.string().optional().default('en'),
82+
// Unknown view values fall back to the default dashboard view.
8083
view: z.enum(['default', 'monthly']).catch('default').default('default'),
84+
// Invalid delta formats fall back to percentage mode.
8185
delta_format: z.enum(['percent', 'absolute', 'both']).catch('percent').default('percent'),
8286
width: z.string().optional(),
8387
height: z.string().optional(),

0 commit comments

Comments
 (0)