catalog-backend: remove unused parseIntegerParam and parseStringParam
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -16,48 +16,6 @@
|
||||
|
||||
import { InputError } from '@backstage/errors';
|
||||
|
||||
/**
|
||||
* Takes a single unknown parameter and makes sure that it's a string that can
|
||||
* be parsed as an integer.
|
||||
*/
|
||||
export function parseIntegerParam(
|
||||
param: unknown,
|
||||
ctx: string,
|
||||
): number | undefined {
|
||||
if (param === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof param !== 'string') {
|
||||
throw new InputError(`Invalid ${ctx}, not an integer on string form`);
|
||||
}
|
||||
|
||||
const parsed = parseInt(param, 10);
|
||||
if (!Number.isInteger(parsed) || String(parsed) !== param) {
|
||||
throw new InputError(`Invalid ${ctx}, not an integer`);
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a single unknown parameter and makes sure that it's a string.
|
||||
*/
|
||||
export function parseStringParam(
|
||||
param: unknown,
|
||||
ctx: string,
|
||||
): string | undefined {
|
||||
if (param === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof param !== 'string') {
|
||||
throw new InputError(`Invalid ${ctx}, not a string`);
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a single unknown parameter and makes sure that it's a single string or
|
||||
* an array of strings, and returns as an array.
|
||||
|
||||
Reference in New Issue
Block a user