Added validator and error message functionality