title: DDD Using Specification pattern for Validation
body: <p>I am thinking of using Specification pattern for validation purposes. The hard thing is how to tell the user why some Specification was not satisfied. What if the <code>Specification.IsSatisfiedBy()</code> will not only return a <code>bool</code> value, but also the reason of failure. It would look something like this:</p>
  
  <pre><code>interface ISpecification&lt;T&gt;
  {
    CheckResult IsSatisfiedBy(T candidate);
  }
  </code></pre>
  
  <p>where <code>CheckResult</code> is:</p>
  
  <pre><code>class CheckResult
  {
    public bool IsSatisfied { get; }
    public string FailureReason { get; }
  }
  </code></pre>
  
  <p>In <a href="http://martinfowler.com/apsupp/spec.pdf" rel="noreferrer">Fowler &amp; Evans</a> work there is a concept of <em>Partially Satisfied Specification</em> whose purpose is to provide explanation what exactly was not satisfied. However in that document, it is implemented as additional method <em>remainderUnsatisfiedBy</em> which returns the Specification which was not accomplished by the <em>Candidate</em>.</p>
  
  <p>So the question is: When using Specification for validation purposes, how to provide feedback to user that a given Specification was not satisfied? Is the solution I've presented above good?</p>