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()
{
}
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());
}
}}