dotnet-starter-kit icon indicating copy to clipboard operation
dotnet-starter-kit copied to clipboard

Implement FluentValidation in a form with multiple input controls.

Open aabordalo opened this issue 1 year ago • 2 comments

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.

image

aabordalo avatar Nov 29 '24 16:11 aabordalo

There is no one to guide this problem?

ghost avatar Dec 17 '24 20:12 ghost

A couple of things needed for this, from the top of my head:

  1. Make sure the Endpoint produces a HttpValidationProblemDetails response for validation errors, and regenerate the apiclient.
  2. 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.

tomaforn avatar Jan 21 '25 12:01 tomaforn