title: OOP Design - Where/When do you Validate properties?
body: <p>I have read a few books on OOP DDD/PoEAA/Gang of Four and none of them seem to cover the topic of validation - it seems to be always assumed that data is valid.</p>
  
  <p>I gather from the answers to this post (<a href="https://stackoverflow.com/q/1651964/153923">OOP Design Question - Validating properties</a>) that a client should only attempt to set a <strong>valid</strong> property value on a domain object.</p>
  
  <p>This person has asked a similar question that remains unanswered: <a href="http://bytes.com/topic/php/answers/789086-php-oop-setters-getters-data-validation#post3136182" rel="nofollow noreferrer">http://bytes.com/topic/php/answers/789086-php-oop-setters-getters-data-validation#post3136182</a></p>
  
  <p>So how do you ensure it is valid? 
  Do you have a 'validator method' alongside every getter and setter?</p>
  
  <ul>
  <li>isValidName()  </li>
  <li>setName()</li>
  <li>getName()</li>
  </ul>
  
  <p>I seem to be missing some key basic knowledge about OOP data validation - can you point me to a book that covers this topic in detail? - ie. covering different types of validation / invariants/ handling feedback / to use Exceptions or not etc </p>