Implementing input validation and error messaging