Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Validation fail with Exception #189

Open
sejerpz opened this issue May 17, 2023 · 4 comments
Open

[Bug] Validation fail with Exception #189

sejerpz opened this issue May 17, 2023 · 4 comments
Labels
Bug Something isn't working Triage Issue needs to be triaged

Comments

@sejerpz
Copy link

sejerpz commented May 17, 2023

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.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)

@sejerpz sejerpz added Bug Something isn't working Triage Issue needs to be triaged labels May 17, 2023
@ghostinside
Copy link

+1 can confirm, working 2.0.3, not working 2.1.0

@RetiredDotaPlayer
Copy link

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.

@Etnic
Copy link

Etnic commented Nov 16, 2023

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'

image

@ghostinside
Copy link

when this bug is going to be fixed & merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants