Tenekon.FluentValidation.Extensions.AspNetCore.Components 1.0.42-alpha-gf27ed5ad86

Prefix Reserved
This is a prerelease version of Tenekon.FluentValidation.Extensions.AspNetCore.Components.
dotnet add package Tenekon.FluentValidation.Extensions.AspNetCore.Components --version 1.0.42-alpha-gf27ed5ad86
                    
NuGet\Install-Package Tenekon.FluentValidation.Extensions.AspNetCore.Components -Version 1.0.42-alpha-gf27ed5ad86
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tenekon.FluentValidation.Extensions.AspNetCore.Components" Version="1.0.42-alpha-gf27ed5ad86" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tenekon.FluentValidation.Extensions.AspNetCore.Components" Version="1.0.42-alpha-gf27ed5ad86" />
                    
Directory.Packages.props
<PackageReference Include="Tenekon.FluentValidation.Extensions.AspNetCore.Components" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tenekon.FluentValidation.Extensions.AspNetCore.Components --version 1.0.42-alpha-gf27ed5ad86
                    
#r "nuget: Tenekon.FluentValidation.Extensions.AspNetCore.Components, 1.0.42-alpha-gf27ed5ad86"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tenekon.FluentValidation.Extensions.AspNetCore.Components@1.0.42-alpha-gf27ed5ad86
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tenekon.FluentValidation.Extensions.AspNetCore.Components&version=1.0.42-alpha-gf27ed5ad86&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tenekon.FluentValidation.Extensions.AspNetCore.Components&version=1.0.42-alpha-gf27ed5ad86&prerelease
                    
Install as a Cake Tool

Tenekon.FluentValidation.Extensions Starts License Activity Discord

🚧 This is a new project. You are very welcome to participate in this project, help shape the public API and share ideas. The project is currently in alpha state, so the public API may change significantly.

Table of Contents

Packages

Package Description
Tenekon.FluentValidation.Extensions.AspNetCore.Components<br/>NuGet Blazor integration for FluentValidation

Tenekon.FluentValidation.Extensions.AspNetCore.Components

An extension to integrate FluentValidation with ASP.NET Core Components (Blazor Components). This library enhances component-level validation in Blazor applications using FluentValidation.

📖 For usage examples, see the Validator Components Cookbook covering common and advanced scenarios.


Features

  • 🌞 Seamless integration with Blazor forms<sup>1</sup>
  • :jigsaw: Validate not only top-level anymore – just wrap each edit model part by a validator component<sup>2,4</sup>
  • :jigsaw: Nestable edit model validators – nested child validator components<sup>2</sup> still hook into the validation of the main form<sup>3</sup>.
  • 🔌 Component-region validation — plug validators<sup>2</sup> into forms or any part of a form or any nested region or subregion.<sup>3</sup>

<small><sup>1</sup>: Any form that provides a cascaded EditContext, even a plain CascadedValue Value="new EditContext(..)">..</CascadedValue> is sufficient.</small><br/> <small><sup>2</sup>: Refers to the usage of validator components of this library.</small><br/> <small><sup>3</sup>: Nested child edit model validators automatically receive the nearest EditContext, captured by the first validator component<sup>2</sup> higher in the hierarchy (usually from a form<sup>1</sup>).</small><br/> <small><sup>4</sup>: EditModelValidatorSubpath and EditModelScope have the capability to create an isolated EditContxt wired to the nearest EditContext<sup>3</sup>.

Quickstart

1. Install the NuGet package: NuGet

dotnet add package Tenekon.FluentValidation.Extensions.AspNetCore.Components

2. Define your validator using FluentValidation:

public class ModelValidator : AbstractValidator<MyModel>
{
    public ModelValidator()
    {
        RuleFor(x => x.Name).NotEmpty();
    }
}

Requires FluentValidation package to be installed.

3. Register the validator in your DI container:

builder.Services.AddValidatorsFromAssemblyContaining<ModelValidator>();

Requires FluentValidation.DependencyInjectionExtensions package to be installed.

4. Use the validator component(s) in your Blazor form:

@code {
    private Model _model = new Model {
        Name = default(string)
        Children = (List<SubModel>)[
            new SubModel {
                Name = default(string)
            }
        ]
    };
}
<EditForm Model="_model" OnValidSubmit="HandleValidSubmit">
    <EditModelValidatorRootpath ValidatorType="typeof(ModelValidator)" />
    <InputText @bind-Value="_model.Name" />
    <ValidationMessage For="() => _model.Name" />
    @foreach(var child in _model.Children) {
        <EditModelValidatorSubpath Model="child" ValidatorType="typeof(SubModelValidator)">
            <InputText @bind-Value="child.Name"/>
            <ValidationMessage For="() => child.Name"/>
            
            <button type="submit">Prematurely Submit</button>
        </EditModelValidatorSubpath>
    }
    <button type="submit">Submit</button>
</EditForm>

Documentation & Resources

Target Framework

  • .NET 8.0

Dependencies

  • FluentValidation 12.x
  • Microsoft.AspNetCore.Components.Forms 8.x
  • FastExpressionCompiler 5.x

Development

git clone https://github.com/tenekon/Tenekon.FluentValidation.Extensions.git
cd Tenekon.FluentValidation.Extensions
dotnet build

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.