Added validate function for user input for challenge 159