Added validation code to add item logic.