Add comprehensive test coverage for services and utilities

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 08:08:22 +01:00
co-authored by Claude Haiku 4.5
parent e3797f32ca
commit 57f8a54dac
23 changed files with 3519 additions and 20 deletions
+8 -5
View File
@@ -88,17 +88,20 @@ export function validateUrlPathSegment(segment: string): void {
* Validate numeric parameter (width, height, quality, etc.)
*/
export function validateNumericParam(value: unknown, min = 0, max = 10000, name = "parameter"): number {
const num = Number(value);
if (!Number.isInteger(num)) {
// Must be an actual number, not a string that looks like a number
if (typeof value !== "number") {
throw new Error(`Invalid ${name}: must be an integer`);
}
if (num < min || num > max) {
if (!Number.isInteger(value)) {
throw new Error(`Invalid ${name}: must be an integer`);
}
if (value < min || value > max) {
throw new Error(`Invalid ${name}: must be between ${min} and ${max}`);
}
return num;
return value;
}
/**