I intend to pass the HttpClient into the validator, not sure how to achieve it.
public class FluentValidator<TValidator> : ComponentBase
where TValidator : IValidator, new()
{
private readonly static char[] separators = new[] { '.', '[' };
private TValidator validator;
[CascadingParameter] private EditContext EditContext { get; set; }
protected override void OnInitialized()
{
validator = new TValidator();
var messages = new ValidationMessageStore(EditContext);
.
.
.
}
}
Here is my Fluent Validator, for which i need to inject the HTTP client from blazor webassembly page.
public class EditProfileValidator : AbstractValidator<EditProfileModel>
{
private HttpClient _Http;
public EditProfileValidator(HttpClient Http)
{
_Http = Http;
}
}
in Blazor Pages
I want to Pass HTTP variable as shown hereunder down to the validator.
The problem is that i get over 200+ error when i include the Http variable as argument.
@inject HttpClient Http
<EditForm EditContext="@profileEditContext" OnSubmit="UpdateProfile">
<FluentValidator TValidator="EditProfileValidator(Http)" />
<ValidationSummary />
NOTE: The following works fine if i remove the Http and remove it from class as well.
<EditForm EditContext="@profileEditContext" OnSubmit="UpdateProfile">
<FluentValidator TValidator="EditProfileValidator" />
<ValidationSummary />