MCPcopy Index your code
hub / github.com/codeaashu/claude-code / validateBoundedIntEnvVar

Function validateBoundedIntEnvVar

src/utils/envValidation.ts:9–38  ·  view source on GitHub ↗
(
  name: string,
  value: string | undefined,
  defaultValue: number,
  upperLimit: number,
)

Source from the content-addressed store, hash-verified

7}
8
9export function validateBoundedIntEnvVar(
10 name: string,
11 value: string | undefined,
12 defaultValue: number,
13 upperLimit: number,
14): EnvVarValidationResult {
15 if (!value) {
16 return { effective: defaultValue, status: 'valid' }
17 }
18 const parsed = parseInt(value, 10)
19 if (isNaN(parsed) || parsed <= 0) {
20 const result: EnvVarValidationResult = {
21 effective: defaultValue,
22 status: 'invalid',
23 message: `Invalid value "${value}" (using default: ${defaultValue})`,
24 }
25 logForDebugging(`${name} ${result.message}`)
26 return result
27 }
28 if (parsed > upperLimit) {
29 const result: EnvVarValidationResult = {
30 effective: upperLimit,
31 status: 'capped',
32 message: `Capped from ${parsed} to ${upperLimit}`,
33 }
34 logForDebugging(`${name} ${result.message}`)
35 return result
36 }
37 return { effective: parsed, status: 'valid' }
38}
39

Callers 4

getMaxOutputLengthFunction · 0.85
getMaxTaskOutputLengthFunction · 0.85
_temp8Function · 0.85

Calls 1

logForDebuggingFunction · 0.85

Tested by

no test coverage detected