MCPcopy
hub / github.com/callstack/agent-device / parseEnumSetValue

Function parseEnumSetValue

src/utils/source-value.ts:118–137  ·  view source on GitHub ↗
(
  definition: SourceValueDefinition,
  value: unknown,
  sourceLabel: string,
  rawKey: string,
)

Source from the content-addressed store, hash-verified

116}
117
118function parseEnumSetValue(
119 definition: SourceValueDefinition,
120 value: unknown,
121 sourceLabel: string,
122 rawKey: string,
123): unknown {
124 const expectedValue = definition.setValue;
125 if (value === expectedValue) return expectedValue;
126 if (typeof value === 'string') {
127 const normalized = value.trim();
128 if (normalized === '' || normalized === 'true' || normalized === '1') return expectedValue;
129 if (normalized === 'false' || normalized === '0') return undefined;
130 }
131 if (value === true) return expectedValue;
132 if (value === false) return undefined;
133 throw new AppError(
134 'INVALID_ARGS',
135 `Invalid value for "${rawKey}" in ${sourceLabel}. Expected boolean-like value for enum flag.`,
136 );
137}

Callers 1

parseSourceValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected