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