File size: 389 Bytes
ab6d29f
 
 
 
742b2a5
ab6d29f
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def validate_input(query):
    """Validate and clean user input"""
    if not query or not query.strip():
        raise ValueError("Input cannot be empty")
    
    # Remove extra whitespace
    cleaned = query.strip()
    
    # Limit length to prevent abuse
    if len(cleaned) > 1000:
        raise ValueError("Input too long. Please limit to 1000 characters.")
    
    return cleaned