How can I add validation to the code you gave me?