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
{{ message }}
This repository was archived by the owner on Dec 26, 2025. It is now read-only.
Description
While testing FluentValidation and Blazored.FluentValidation with the InputText component's ValueChanged event, observed that the validation message works correctly when using the Tab key or clicking away from the field. However, when the Enter key is used, the validation message does not appear and only flashes briefly.
@using Blazored.FluentValidation
@using FluentValidation
<div style="margin: 150px auto; width: 50%">
<EditForm Model="@_annotation">
<FluentValidationValidator @ref="_testFluentValidationValidator" />
<InputText class="form-control"
Value="@_annotation.Name"
ValueChanged="ChangeValue"
ValueExpression="@(() => _annotation.Name)"></InputText>
<ValidationMessage For="@(() => _annotation.Name)" />
</EditForm>
</div>
@code {
private FluentValidationValidator? _testFluentValidationValidator;
private Annotation _annotation = new();
protected async Task ChangeValue(string newValue)
{
_annotation.Name = newValue;
var result = (await _testFluentValidationValidator!.ValidateAsync(options => options.IncludeRuleSets("TestNames")));
if (result)
{
await Task.Delay(100);
}
else
{
await Task.Delay(100);
}
}
public class AnnotationValidator : AbstractValidator<Annotation>
{
public AnnotationValidator()
{
RuleSet("TestNames", () =>
{
RuleFor(e => e.Name)
.NotEmpty().WithMessage("Please enter a name.")
.MinimumLength(3).WithMessage($"Name must be longer than 2 characters.");
});
}
}
public class Annotation
{
public string Name { get; set; }
}
}
To Reproduce
Steps to reproduce the behavior:
Run the code snippet provided above.
Focus on the input field and type "A".
Press the Enter key.
Expected behavior
The validation message needs to be displayed properly.
Video of the issue:
1436.mp4
Hosting Model (is this issue happening with a certain hosting model?):
Blazor Server
Blazor WebAssembly
Additional context
While testing the same scenario with Jeremy FluentValidation, it worked well.