myspace134v / modules /input_handler.py
rdune71's picture
new1
ab6d29f
raw
history blame contribute delete
389 Bytes
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