Need help with FluentValidation?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Blazored
273 Stars 34 Forks MIT License 49 Commits 20 Opened issues

Description

A library for using FluentValidation with Blazor

Services available

!
?

Need anything else?

Contributors list

FluentValidation

A library for using FluentValidation with Blazor

Build & Test Main

Nuget

Installing

You can install from Nuget using the following command:

Install-Package Blazored.FluentValidation

Or via the Visual Studio package manger.

Basic Usage

Start by add the following using statement to your root

_Imports.razor
.
@using Blazored.FluentValidation

You can then use it as follows within a

EditForm
component.
    
    

<p>
    <label>Name: </label>
    <inputtext></inputtext>
</p>

<p>
    <label>Age: </label>
    <inputnumber></inputnumber>
</p>

<p>
    <label>Email Address: </label>
    <inputtext></inputtext>
</p>

<button type="submit">Save</button>

@code { Person Person { get; set; } = new Person();

void SubmitValidForm()
{
    Console.WriteLine("Form Submitted Successfully!");
}

}

Finding Validators

By default, the component will check for validators registered with DI first. If it can't find, any it will then try scanning the applications assemblies to find validators using reflection.

You can control this behaviour using the

DisableAssemblyScanning
parameter. If you only wish the component to get validators from DI, set the value to
true
and assembly scanning will be skipped.

You can find examples of different configurations in the sample projects. The Blazor Server project is configured to load validators from DI only. The Blazor WebAssembly project is setup to load validators using reflection.

Note: When scanning assemblies the component will swallow any exceptions thrown by that process. This is to stop exceptions thrown by scanning third party dependencies crashing your app.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.