I'm using FluentValidation version: 8.5.1 in my Asp.Net Core 3.0 Razor Pages project.
I have a class derived from base class as shown below:
public class BranchEditViewModel : BranchViewModel
{
public Guid Id { get; set; }
public bool Active { get; set; }
}
I'm trying to validate my derived class in my update method as shown below:
public async Task<IActionResult> OnPutAsync([FromForm] BranchEditViewModel model)
But this doesn't work for some reason. The Validations are not getting called.
When I create AbstractValidator
for my base class as shown below, the validator is not getting called.
public class BranchViewModelValidator : AbstractValidator<BranchViewModel>
But if I create AbstractValidator
for my dervied class as shown below, the validator is getting called.
public class BranchViewModelValidator : AbstractValidator<BranchEditViewModel>
Please can you assist on why this is not working with base class? Am I doing something wrong?