Add comprehensive test coverage for services and utilities
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user