Reputation: 21
I have an edit form that uses Fluent validation for validations. Fluent is returning multiple validation messages for a property but this section in the edit form always displaying the first message in that list:
<ValidationMessage For="@(() => model.input)" />
How to display all the validation messages?
Thanks
Upvotes: 2
Views: 35
Reputation: 30310
ValidationMessage
outputs all the messages for a specific field in the current EditConntext
's ValidationMessageStore
.
The relevant code from the source is Link to Source Code :
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
foreach (var message in CurrentEditContext.GetValidationMessages(_fieldIdentifier))
{
builder.OpenElement(0, "div");
builder.AddAttribute(1, "class", "validation-message");
builder.AddMultipleAttributes(2, AdditionalAttributes);
builder.AddContent(3, message);
builder.CloseElement();
}
}
Therefore, your Fluent Validation code isn't doing what you think it's doing. But, without any code, ?????.
Upvotes: 1