Added validate function and error message on invalid action