Open sejerpz opened 1 year ago
+1 can confirm, working 2.0.3, not working 2.1.0
Not sure if the issue I have is the same, but I'm receiving similar message stating that a ValidatorForA cannot be used to validate instance of B, if A has a property of complex type B.
Using SetValidator
in ValidatorForA to explicitly set a ValidatorForB does help to some extent. But once you start changing the value of A.B.AnyPropertyOfB, same error occurs.
same for me. It is working with version 2.0.3, not working 2.1.0
System.InvalidOperationException: Cannot validate instances of type 'UlohaData'. This validator can only validate instances of type 'SimpleUlohaForm'
when this bug is going to be fixed & merged?
Describe the bug
FluentValidation version 2.1.0, FluentValidator 11.4.0 Validation fails with this exception when using the validator property.
It works with FluentValidation version 2.0.3, FluentValidator 10.4.0
Exception thrown:
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'kQzRJlSJayDH0mqPFgkuf8f79oRMmi-_4_c1eBuQqwY'.
System.InvalidOperationException: Cannot validate instances of type 'TextEntry'. This validator can only validate instances of type 'ExampleDashletConfigDialogViewModel'. at FluentValidation.ValidationContextb1>d.MoveNext()
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.<>c.b 128_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 230(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
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)
[2023-05-17T11:01:03.497Z] Error: System.InvalidOperationException: Cannot validate instances of type 'TextEntry'. This validator can only validate instances of type 'ExampleDashletConfigDialogViewModel'.
at FluentValidation.ValidationContext`1.GetFromNonGenericContext(IValidationContext context) in //src/FluentValidation/IValidationContext.cs:line 237
at FluentValidation.AbstractValidator
1.GetFromNonGenericContext(IValidationContext context) in /_/src/FluentValidation/IValidationContext.cs:line 237 at FluentValidation.AbstractValidator
1.FluentValidation.IValidator.ValidateAsync(IValidationContext context, CancellationToken cancellation) in /_/src/FluentValidation/AbstractValidator.cs:line 158 at Blazored.FluentValidation.EditContextFluentValidationExtensions.ValidateField(EditContext editContext, ValidationMessageStore messages, FieldIdentifier fieldIdentifier, IServiceProvider serviceProvider, Boolean disableAssemblyScanning, IValidator validator) at Blazored.FluentValidation.EditContextFluentValidationExtensions.<>cDisplayClass4_0.<1.FluentValidation.IValidator.ValidateAsync(IValidationContext context, CancellationToken cancellation) in /_/src/FluentValidation/AbstractValidator.cs:line 158 at Blazored.FluentValidation.EditContextFluentValidationExtensions.ValidateField(EditContext editContext, ValidationMessageStore messages, FieldIdentifier fieldIdentifier, IServiceProvider serviceProvider, Boolean disableAssemblyScanning, IValidator validator) at Blazored.FluentValidation.EditContextFluentValidationExtensions.<>c__DisplayClass4_0.<<AddFluentValidation>b__1>d.MoveNext() --- End of stack trace from previous location --- at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_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 --- 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)