Implement input validation