MCPcopy Create free account
hub / github.com/BCsabaEngine/svelteesp32 / validateSizeOption

Function validateSizeOption

src/commandLine.ts:325–336  ·  view source on GitHub ↗
(configObject: Record<string, unknown>, key: string)

Source from the content-addressed store, hash-verified

323}
324
325function validateSizeOption(configObject: Record<string, unknown>, key: string): void {
326 const value = configObject[key];
327 if (value === undefined) return;
328 if (typeof value === 'string')
329 try {
330 configObject[key] = parseSize(value, key);
331 } catch {
332 throw new TypeError(`Invalid ${key} in RC file: ${value} (must be a positive number with optional k/m suffix)`);
333 }
334 else if (typeof value !== 'number' || Number.isNaN(value) || value <= 0)
335 throw new TypeError(`Invalid ${key} in RC file: ${value} (must be a positive number)`);
336}
337
338function validateRcConfig(config: unknown, rcPath: string): IRcFileConfig {
339 if (typeof config !== 'object' || config === null) throw new Error(`RC file ${rcPath} must contain a JSON object`);

Callers 1

validateRcConfigFunction · 0.85

Calls 1

parseSizeFunction · 0.85

Tested by

no test coverage detected