Custom validation class in blazor is not working as expected.
See original GitHub issueFirst of all, Custom validation class attributes documentation is quite ambiguous and lack of clear instructions. It is not even stated that where to put the following code:
var editContext = new EditContext(model);
editContext.SetFieldCssClassProvider(new MyFieldClassProvider());
I have assumed that the above code has to be put inside at the beginning of HandleValidSubmit method. If I do so then it does not work on Model validation by validation attributes (data annotations) as model validation is done even before hitting the HandleValidSubmit method.
Secondly, If I am to do so then it means there is no global option to configure this. Rather I have to call the above code in every form submit which is even not working as expected?
Please confirm whether I have configured the Custom validation class attributes (as described above) correctly or it is a bug.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)

Top Related StackOverflow Question
@mkArtakMSFT Surely! I shall do. We ❤️ Blazor a lot. It’s a mind-blowing framework. We want to see it as fully stable as Angular. Thanks to all you guys behind this framework.
@mkArtakMSFT … The PR is up at https://github.com/dotnet/AspNetCore.Docs/pull/21634.
I put a piece in there at the end that mentions conditionally checking a subset of fields.
I’ll touch it again later when I reach the topic on my UE pass. For example, a fully working cut-'n-paste example might be best, and I might work that up later. Let’s see if what’s on the PR is good enough for now.