https://github.com/tenekon/tenekon.fluentvalidation.extensions
Provides the FluentValidation extension for Microsoft.AspNetCore.Components
https://github.com/tenekon/tenekon.fluentvalidation.extensions
blazor components dotnet editform fluentvalidation form-validation validation validator
Last synced: 7 months ago
JSON representation
Provides the FluentValidation extension for Microsoft.AspNetCore.Components
- Host: GitHub
- URL: https://github.com/tenekon/tenekon.fluentvalidation.extensions
- Owner: tenekon
- License: mit
- Created: 2025-06-26T21:48:51.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-11T23:29:32.000Z (11 months ago)
- Last Synced: 2025-07-12T02:27:13.801Z (11 months ago)
- Topics: blazor, components, dotnet, editform, fluentvalidation, form-validation, validation, validator
- Language: C#
- Homepage:
- Size: 115 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tenekon.FluentValidation.Extensions [](https://github.com/tenekon/Tenekon.FluentValidation.Extensions/stargazers) [](https://github.com/tenekon/Tenekon.FluentValidation.Extensions/blob/main/LICENSE) [](https://github.com/tenekon/Tenekon.FluentValidation.Extensions/commits/main/) [](https://discord.gg/VCa8ePSAqD)
> :construction: 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](#packages)
- [`Tenekon.FluentValidation.Extensions.AspNetCore.Components`](#tenekonfluentvalidationextensionsaspnetcorecomponents)
- [Features](#features)
- [Quickstart](#quickstart)
- [Documentation \& Resources](#documentation--resources)
- [Target Framework](#target-framework)
- [Dependencies](#dependencies)
- [Development](#development)
- [License](#license)
## Packages
| Package Description | |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| [`Tenekon.FluentValidation.Extensions.AspNetCore.Components`](https://www.nuget.org/packages/Tenekon.FluentValidation.Extensions.AspNetCore.Components)
[](https://www.nuget.org/packages/Tenekon.FluentValidation.Extensions.AspNetCore.Components) | Blazor integration for FluentValidation |
### `Tenekon.FluentValidation.Extensions.AspNetCore.Components`
An extension to integrate [FluentValidation](https://fluentvalidation.net/) with ASP.NET Core Components (Blazor Components). This
library enhances component-level validation in Blazor applications using FluentValidation.
> :open_book: For usage examples, see the [Validator Components Cookbook](src/Tenekon.FluentValidation.Extensions.AspNetCore.Components/COOKBOOK.md) covering common and advanced scenarios.
---
### Features
- :sun_with_face: **Seamless integration with Blazor forms**1
- :jigsaw: **Validate not only top-level anymore** – just wrap each edit model part by a validator component2,4
- :jigsaw: **Nestable edit model validators** – nested child validator components2 still hook into the validation of the main form3.
- :electric_plug: **Component-region validation** — plug validators2 into forms or any part of a form or any nested region or subregion.3
1: Any form that provides a cascaded `EditContext`, even a plain `CascadedValue Value="new EditContext(..)">..` is sufficient.
2: Refers to the usage of validator components of this library.
3: Nested child edit model validators automatically receive the nearest `EditContext`, captured by the first validator component2 higher in the hierarchy (usually from a form1).
4: `EditModelValidatorSubpath` and `EditModelScope` have the capability to create an isolated `EditContxt` wired to the nearest `EditContext`3.
### Quickstart
**1\. Install the NuGet package:** [](https://www.nuget.org/packages/Tenekon.FluentValidation.Extensions.AspNetCore.Components)
```bash
dotnet add package Tenekon.FluentValidation.Extensions.AspNetCore.Components
```
**2\. Define your validator** using `FluentValidation`:
```csharp
public class ModelValidator : AbstractValidator
{
public ModelValidator()
{
RuleFor(x => x.Name).NotEmpty();
}
}
```
> Requires `FluentValidation` package to be installed.
**3\. Register the validator** in your DI container:
```csharp
builder.Services.AddValidatorsFromAssemblyContaining();
```
> Requires `FluentValidation.DependencyInjectionExtensions` package to be installed.
**4\. Use the validator component(s) in your Blazor form**:
```razor
@code {
private Model _model = new Model {
Name = default(string)
Children = (List)[
new SubModel {
Name = default(string)
}
]
};
}
@foreach(var child in _model.Children) {
Prematurely Submit
}
Submit
```
### Documentation & Resources
- :open_book: **Cookbook**: [Validator Components Cookbook](src/Tenekon.FluentValidation.Extensions.AspNetCore.Components/COOKBOOK.md) —
Examples & use cases for all common and advanced scenarios.
- :bricks: **Architecture** [Validator Components Architecture](src/Tenekon.FluentValidation.Extensions.AspNetCore.Components/ARCHITECTURE.md) — Architectural approach of the components, and their integration with Blazor's EditContext.
- :microscope: **Flow Logic**: [Validator Components Flow Logic](src/Tenekon.FluentValidation.Extensions.AspNetCore.Components/FLOWLOGIC.md) — Visual guide to
how edit model validators interact with each other and Blazor's `EditContext`.
### Target Framework
* `.NET 8.0`
### Dependencies
* `FluentValidation` 12.x
* `Microsoft.AspNetCore.Components.Forms` 8.x
* `FastExpressionCompiler` 5.x
## Development
```bash
git clone https://github.com/tenekon/Tenekon.FluentValidation.Extensions.git
cd Tenekon.FluentValidation.Extensions
dotnet build
```
## License
MIT License - see [LICENSE](LICENSE) for details.