MCPcopy
hub / github.com/Fission-AI/OpenSpec / validateConfigKeyPath

Function validateConfigKeyPath

src/core/config-schema.ts:44–68  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

42 * Unknown top-level keys are rejected unless explicitly allowed by the caller.
43 */
44export function validateConfigKeyPath(path: string): { valid: boolean; reason?: string } {
45 const rawKeys = path.split('.');
46
47 if (rawKeys.length === 0 || rawKeys.some((key) => key.trim() === '')) {
48 return { valid: false, reason: 'Key path must not be empty' };
49 }
50
51 const rootKey = rawKeys[0];
52 if (!KNOWN_TOP_LEVEL_KEYS.has(rootKey)) {
53 return { valid: false, reason: `Unknown top-level key "${rootKey}"` };
54 }
55
56 if (rootKey === 'featureFlags') {
57 if (rawKeys.length > 2) {
58 return { valid: false, reason: 'featureFlags values are booleans and do not support nested keys' };
59 }
60 return { valid: true };
61 }
62
63 if (rawKeys.length > 1) {
64 return { valid: false, reason: `"${rootKey}" does not support nested keys` };
65 }
66
67 return { valid: true };
68}
69
70/**
71 * Get a nested value from an object using dot notation.

Callers 2

config.test.tsFile · 0.85
registerConfigCommandFunction · 0.85

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected