You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.ValidationContext1.GetFromNonGenericContext(IValidationContext context) in /_/src/FluentValidation/IValidationContext.cs:line 237 at FluentValidation.AbstractValidator1.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.<b__1>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(TaskCompletionSource1 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) [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.ValidationContext1.GetFromNonGenericContext(IValidationContext context) in //src/FluentValidation/IValidationContext.cs:line 237
at FluentValidation.AbstractValidator1.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(TaskCompletionSource1 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)
The text was updated successfully, but these errors were encountered:
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.
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.ValidationContext
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 158at Blazored.FluentValidation.EditContextFluentValidationExtensions.ValidateField(EditContext editContext, ValidationMessageStore messages, FieldIdentifier fieldIdentifier, IServiceProvider serviceProvider, Boolean disableAssemblyScanning, IValidator validator)
at Blazored.FluentValidation.EditContextFluentValidationExtensions.<>c__DisplayClass4_0.<b__1>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__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) [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 237at 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.<>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)
The text was updated successfully, but these errors were encountered: