title: Fluent apply RuleFor only if value is not null
body: <p>Following on from my previous question, I have a <code>nullable</code> <code>char</code> named <code>source</code> in my <code>Transaction</code> class.</p>
  
  <pre><code>    //source isnt required but when present must be 1 character 'I' or 'M'            
      RuleFor(transaction =&gt; transaction.source.ToString())
          .Matches("^[IM]?$")                
          .When(t =&gt; t.source.Value != null);
  </code></pre>
  
  <p>As <code>Matches</code> and <code>When</code> are not available for a <code>char</code>, I am using the <code>.ToString()</code> method however, if when a new <code>Transaction</code> object is generated, the source property is <code>null</code>, the application fails due to being unable to convert a <code>null</code> source to a <code>string</code>.</p>
  
  <p>Can anyone suggest a way of running the validation for source <strong>ONLY</strong> if source is not <code>null</code>? I assumed that the When expression that I have written would do this, and this part of the validation process would be skipped if source was <code>null</code> however it tries to process the <code>ToString()</code> part of the validation regardless and thus causes an error.</p>