title: Constraint vs. Validation?
body: <p>I am working with Windows Forms Databinding, implementing interfaces like <code>IDataErrorInfo</code>.  In order for this to work, the domain(or business) object is allowed to be in an invalid state.  In fact, the domain object needs to retain the invalid value as the user entered it for <code>IDataErrorInfo</code> to work properly.  As long as the object isn't persisted in invalid state, we're ok.</p>
  
  <p>However, as the subject line suggests I was wondering whether there is a difference between contraint and validation.  The former would prevent the user from making the change AT ALL, the later is the type of validation I've described above.</p>
  
  <p>Let me explain - if you have a collection of <code>Person</code> and <code>Person</code> has a <code>SSN</code> property.  The <code>PersonCollection</code> is keyed on <code>SSN</code>, meaning in the collection, there cannot be two <code>Persons</code> with the same <code>SSN</code>.  If we allow temporary invalid state on <code>Person</code>, we introduce a situation where there are two <code>Persons</code> with duplicate <code>SSN</code> in the collection, albeit temporarily.  This can lead to issues where another object working with <code>PersonCollection</code>, looking for a <code>Person</code> object with the duplicated <code>SSN</code>, getting two objects.</p>
  
  <p>So, to me, it seems that certain type of validations need to be constraints rather than (post-change) validations.</p>
  
  <p>Thoughts?</p>