title: .Net Fluent Validation set execution order
body: <p>I need to set execution order for validation so that it stops validating after the first fail.</p>
  
  <p>However <a href="https://www.google.hr/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CBwQFjAA&amp;url=http://fluentvalidation.codeplex.com/discussions/352581&amp;ei=X4eZU96xKaWxywPLn4CICg&amp;usg=AFQjCNFziV9I1uQRffJnVtomCr1Tca9V1A&amp;sig2=5PM0VQKHQqLLq_Eu2hNpHg&amp;bvm=bv.68911936,d.bGQ&amp;cad=rja" rel="nofollow">this is not available</a>, so i am wondering what other way to do this.</p>
  
  <p>Normally i would have something like this:</p>
  
  <pre><code>public Constructor(){
  
      // Simple validation
      RuleFor(x =&gt; x.Id).NotNull().NotEmpty();
  
      // advanced validation
      // item must exist in database
      RuleFor(x =&gt; x.Id).Must(ExistsInDatabase);
  
      // item must exist in database previously
      // item must be some of the allowed names -- fetched from db
      RuleFor(x =&gt; x.Id).Must(BeAReferenceInSomeTable);
  
      private bool ExistsInDatabase(){}
  
      private bool BeAReferenceInSomeTable(){}
  
  }
  </code></pre>
  
  <p>But with this BeAReferenceInSomeTable can be executed prior to ExistsInDatabase.
  So BeAReferenceInSomeTable validation will throw exception when Id does not exist in table instead of validation failing because of ExistsInDatabase validation.</p>
  
  <p>To solve this first that comes to mind is something like this:</p>
  
  <pre><code>public Constructor(){
  
      CascadeMode = FluentValidation.CascadeMode.StopOnFirstFailure;
  
      // simple validation stays the same
      ...
  
      // advanced validation
      RuleFor(x =&gt; x.Id)
          .Must(ExistsInDatabase)
          .Must(BeAReferenceInSomeTable)
          .When(x =&gt; !string.IsNullOrEmpty(x.Id) &amp;&amp;
                      !string.IsNullOrEmpty(x.Name)
          );  
  }
  </code></pre>
  
  <p>But in this case how do i set a propper message for validation since message must be given prior to execution.</p>