how to asynchronous validation in blazor srver?

949 Views Asked by At

In Blazor Server i use <FluentValidationValidator /> to validate the form also i use MustAsync in my validator But when the form is submitted, Validation is executed, but the program does not wait for the end of Validation and the execution of the program continues.

<EditForm Model="Model">
    <FluentValidationValidator Validator="FormValidator"></FluentValidationValidator>
    <ValidationSummary></ValidationSummary>
    ...
</EditForm>

and my validator

public class FormValidator : AbstractValidator<Model>
{
    RuleFor(e => e.Name)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .MustAsync(BeUniqNameAsync).WithMessage("Name Must Be Unique");
}
0

There are 0 best solutions below