Validation extensions for Microsoft Blazor / FluentValidation
MIT License
Blazor-Validation is a validation agnostic library for validating forms in Blazor- Microsoft aspdotnet Blazor project.
You can download the latest release / pre-release NuGet packages from the official NuGet pages:
<EditForm>
in your razor files, add <Morris.Blazor.Validation.Validate/>
using Morris.Blazor.Validation
and then add the relevant validation in the ConfigureServices
method.services.AddFormValidation(config => config.AddDataAnnotationsValidation());
services.AddFormValidation(config => config.AddFluentValidation(typeof(SomeValidator).Assembly));
It is possible to add as many validation providers as you wish
services.AddFormValidation(config =>
config
.AddDataAnnotationsValidation()
.AddFluentValidation(typeof(SomeValidator).Assembly)
);
Also you can have the FluentValidation
extension scan multiple assemblies
services.AddFormValidation(config =>
config
.AddFluentValidation(
typeof(SomeValidator).Assembly,
typeof(ClassInAnotherDll).Assembly,
andAnotherAssembly,
andYetAnotherAssembly));
The standard Blazor components <ValidationSummary>
and <ValidationMessage>
will now work with your selected validation options.
More sample projects will be added as the framework develops.
Services.TryAddScoped
instead of Services.AddScoped
for validators, in casebool
from EditContext.ValidatePropertyEditContext.ValidateObjectTree