MCPcopy Create free account
hub / github.com/freecodexyz/free-code / validateFlagArgument

Function validateFlagArgument

src/utils/shell/readOnlyCommandValidation.ts:1650–1670  ·  view source on GitHub ↗
(
  value: string,
  argType: FlagArgType,
)

Source from the content-addressed store, hash-verified

1648 * Validates flag arguments based on their expected type
1649 */
1650export function validateFlagArgument(
1651 value: string,
1652 argType: FlagArgType,
1653): boolean {
1654 switch (argType) {
1655 case 'none':
1656 return false // Should not have been called for 'none' type
1657 case 'number':
1658 return /^\d+$/.test(value)
1659 case 'string':
1660 return true // Any string including empty is valid
1661 case 'char':
1662 return value.length === 1
1663 case '{}':
1664 return value === '{}'
1665 case 'EOF':
1666 return value === 'EOF'
1667 default:
1668 return false
1669 }
1670}
1671
1672/**
1673 * Validates the flags/arguments portion of a tokenized command against a config.

Callers 1

validateFlagsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected