title: C# fluent validation of interface underlaying object
body: <p>I got an azure function, I receive a Json the json contains</p>
  <pre><code>List&lt;Iinterface&gt; objects {get;set;}
  </code></pre>
  <p>then I can have several object implementing Iinterface</p>
  <pre><code>public class A : Iinterface { ... }
  </code></pre>
  <p>The json converter actually resolves the types, so on a list's item if I invoke .GetType i get the correct underlaying type!</p>
  <p>But then I need to validate according to the underlaying type!</p>
  <p>I got this, but can I do it better?</p>
  <pre><code>public class IinterfaceValidator : AbstractValidator&lt;Iinterface&gt;
      {
          public IinterfaceValidator (AValidator aValidator)
          {
              When(x =&gt; x.GetType() == typeof(A), () =&gt;
              {
                  RuleFor(x =&gt; (A)x)
                      .SetValidator(aValidator);
              });
          }
      }
  </code></pre>