dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

Blazor EditForm does not validate all items in the form #28602

Closed OFark closed 3 years ago

OFark commented 3 years ago

Describe the bug

Blazor EditForm does not validate all items in the form

To Reproduce

See: #13345

This has been marked as resolved, but Blazor still isn't traversing Fields for DataAnnotation validation.

I'm using the very latest .Net 5 all updated, the project is only about 2 months old.

My EditForm model has a list of items, those items have bools and strings bound to checkboxes and input text boxes and none of them are being validated.

mrpmorris commented 3 years ago

Use ObjectGraphDataAnnotationsValidator instead of DataAnnotationsValidator

OFark commented 3 years ago

Ok, so ObjectGraphDataAnnotationsValidator does work as long as you use [ValidateComplexType] to tell Blazor to traverse. However, is there any way to get this to utilize HTML5 validation? So web pages highlight and point to invalid fields?

mkArtakMSFT commented 3 years ago

Thanks for contacting us. The Blazor validation doesn't integrate more with HTML5 validation as you describe above. If you'd like this to be a feature, please file a separate issue with detailed justification why it's important and what scenarios it'll be useful in. We'll keep it on our backlog then to see how community will like it.