feat(cell validation): add comprehensive data validation capabilities (#37)

- Add cell_validation.py module for Excel data validation metadata extraction
- Implement get_data_validation_for_cell() and get_all_validation_ranges()
- Include validation metadata in read_data_from_excel responses automatically
- Add get_data_validation_info MCP tool for validation rule summaries
- Resolve range references in list validations to actual cell values
- Support all validation types: list, whole, decimal, date, time, textLength
- Include operators (between, notBetween, equal, greaterThan, etc.) in metadata

This allows LLMs to understand Excel validation constraints including
dropdown options, numeric ranges, date constraints, and text length limits.
This commit is contained in:
Nate
2025-06-06 21:42:00 -07:00
committed by GitHub
parent b2c9ce8e6a
commit bb537b35be
5 changed files with 393 additions and 19 deletions

View File

@ -337,3 +337,23 @@ validate_excel_range(
- `start_cell`: Starting cell of range
- `end_cell`: Optional ending cell of range
- Returns: Validation result message
### get_data_validation_info
Get data validation rules and metadata for a worksheet.
```python
get_data_validation_info(filepath: str, sheet_name: str) -> str
```
- `filepath`: Path to Excel file
- `sheet_name`: Target worksheet name
- Returns: JSON string containing all data validation rules with metadata including:
- Validation type (list, whole, decimal, date, time, textLength)
- Operator (between, notBetween, equal, greaterThan, lessThan, etc.)
- Allowed values for list validations (resolved from ranges)
- Formula constraints for numeric/date validations
- Cell ranges where validation applies
- Prompt and error messages
**Note**: The `read_data_from_excel` tool automatically includes validation metadata for individual cells when available.