However, when i change the drop down list for the departments, i get the following exception (taken from the browser console)
blazor.server.js:15 [2020-02-06T17:39:01.855Z] Error: System.TypeLoadException: Unable to locate a validator of type FluentValidation.IValidator`1[[ContosoUniversity.Domain.UniversityAggregate.Department, ContosoUniversity.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] or FluentValidation.AbstractValidator`1[[ContosoUniversity.Domain.UniversityAggregate.Department, ContosoUniversity.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
at Blazored.FluentValidation.EditContextFluentValidationExtensions.GetValidatorForModel(IServiceProvider serviceProvider, Object model)
at Blazored.FluentValidation.EditContextFluentValidationExtensions.ValidateField(EditContext editContext, ValidationMessageStore messages, FieldIdentifier fieldIdentifier, IServiceProvider serviceProvider, IValidator validator)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)
And i can't seem to work out how to fix this issue. The validator for the form looks like this
public class Validator : AbstractValidator<Command>
{
public Validator()
{
RuleFor(p => p.Number).NotEmpty();
RuleFor(p => p.Title)
.SetValidator(new TitleValidator());
RuleFor(p => p.Credits)
.SetValidator(new CreditsValidator());
}
}
Which means i don't want/need to validate on the department field. If i add a blank validator in for the department, its seems to work ok.
public class Validator : AbstractValidator<Command>
{
public Validator()
{
RuleFor(p => p.Number).NotEmpty();
RuleFor(p => p.Title)
.SetValidator(new TitleValidator());
RuleFor(p => p.Credits)
.SetValidator(new CreditsValidator());
RuleFor(p => p.Department)
.SetValidator(new DepartmentValidator());
}
}
public class DepartmentValidator : AbstractValidator<Department>
{
public DepartmentValidator()
{
}
}
Any ideas why this would be happening? I've tried debugging it but the debug tools for blazor are lacking a bit at the moment.
I'm just having a few problems with this library and nested types.
I have the following page
However, when i change the drop down list for the departments, i get the following exception (taken from the browser console)
And i can't seem to work out how to fix this issue. The validator for the form looks like this
Which means i don't want/need to validate on the department field. If i add a blank validator in for the department, its seems to work ok.
Any ideas why this would be happening? I've tried debugging it but the debug tools for blazor are lacking a bit at the moment.
Cheers Tom