validation¶
academic_doc_generator.core.validation
¶
Validation logic for configuration and environment.
validate_api_keys()
¶
Check which LLM APIs are configured.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of available API names. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no APIs are configured. |
Source code in src/academic_doc_generator/core/validation.py
validate_pdf_path(folder_path, filename, allow_docx=False)
¶
Get validated PDF or DOCX file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_path
|
str
|
Base folder path. |
required |
filename
|
str
|
Name of the PDF or DOCX file. |
required |
allow_docx
|
bool
|
Whether to allow Word (.docx) files. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to PDF or DOCX file. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path attempts directory traversal or contains invalid characters. |
FileNotFoundError
|
If PDF or DOCX does not exist. |
Security
- Prevents directory traversal (../)
- Prevents absolute paths
- Validates file extension