C
C#6mo ago
Prateek

How to show validation message for a nested object's property in a list in blazor

I have 2 models Customer and Contact. A customer can have 1 or more contacts. I'm using EditForm and Mudblazor with ObjectGraphDataAnnotations Validator and a custom validation component (taken from Microsoft Documentation). I'm using the custom validation component to validate the customer name is unique by checking the database (which works correctly) and I'm able to validate that the contactNames in the list of contact objects are unique but i'm unable to show the validation message for that particular field. I'm only able to see this validation message in the validation summary. I'm passing the validation message using a dictionary of field and its value. I've tried passing the field name as $"customer.Contacts[{index}].ContactName" (The relevant part of the code is under the 1st comment from the bottom in the AddCustomer.razor file) but it doesn't seem to work. For code and more details refer to https://github.com/MudBlazor/MudBlazor/discussions/8092
GitHub
How to show validation message for a nested object's property in a ...
I have 2 models Customer and Contact. A customer can have 1 or more contacts. I'm using EditForm and Mudblazor with ObjectGraphDataAnnotations Validator and a custom validation component (taken...
0 Replies
No replies yetBe the first to reply to this messageJoin