Implementing validate()