public abstract class Animal , IValidatableObject
{
public string Id {get;set;}
public string Name {get;set;}
public virtual IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (this.Name == "animal")
{
yield return new ValidationResult("Invalid Name From base", new[] { "Name" });
}
}
}
public class Dog: Animal, IValidatableObject
{
public string Owner {get;set;}
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
/*
Here call base validate
*/
if (this.Name == "dog")
{
yield return new ValidationResult("Invalid Name From dog", new[] { "Name" });
}
}
}
I have a base class Animal
which implements IValidatableObject
, now from Dog
sub-class's Validate
method which also implements IValidatableObject
, I want to call base class's Validate
method.
I tried doing (it doesn't call base class's validate)
base.Validate(validationContext);