MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / validate_api_key

Function validate_api_key

codewiki/cli/utils/validation.py:55–79  ·  view source on GitHub ↗

Validate API key format. Args: api_key: API key to validate min_length: Minimum key length Returns: Validated API key Raises: ConfigurationError: If API key is invalid

(api_key: str, min_length: int = 10)

Source from the content-addressed store, hash-verified

53
54
55def validate_api_key(api_key: str, min_length: int = 10) -> str:
56 """
57 Validate API key format.
58
59 Args:
60 api_key: API key to validate
61 min_length: Minimum key length
62
63 Returns:
64 Validated API key
65
66 Raises:
67 ConfigurationError: If API key is invalid
68 """
69 if not api_key or not api_key.strip():
70 raise ConfigurationError("API key cannot be empty")
71
72 api_key = api_key.strip()
73
74 if len(api_key) < min_length:
75 raise ConfigurationError(
76 f"API key too short (minimum {min_length} characters)"
77 )
78
79 return api_key
80
81
82def validate_model_name(model: str) -> str:

Callers 1

config_setFunction · 0.90

Calls 1

ConfigurationErrorClass · 0.90

Tested by

no test coverage detected