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