dotnet-starter-kit
dotnet-starter-kit copied to clipboard
Implement FluentValidation in a form with multiple input controls.
Validation error messages are not positioned next to the corresponding input controls. Instead, they appear in a different location, making it difficult for users to identify which input control has the error.
There is no one to guide this problem?
A couple of things needed for this, from the top of my head:
- Make sure the Endpoint produces a HttpValidationProblemDetails response for validation errors, and regenerate the apiclient.
- Extend the ApiHelper to handle such errors with code similar to this:
catch (ApiException<HttpValidationProblemDetails> ex)
{
if (ex.Result.Errors is not null)
{
customValidation?.DisplayErrors(ex.Result.Errors);
}
else
{
snackbar.Add("Something went wrong!", Severity.Error);
}
}
I think something similar already exists in V1, you could have a look there for other ideas.