Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: RuleFor Object

$
0
0
Replying to myself, in order someone there is in same situation
The key is to cast object to right type.

public class ClassAValidator : AbstractValidator<ClassA>
{
public ClassAValidator()

{
   When(c => c.ItemSelector == ItemSelectorEnum.TypeA), () =>
      {
         RuleFor(c => c.Item as TypeAClass).SetValidator(new TypeAClassValidator());
      }
}
}

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>