FormKit.FluentValidation
1.7.0
dotnet add package FormKit.FluentValidation --version 1.7.0
NuGet\Install-Package FormKit.FluentValidation -Version 1.7.0
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="FormKit.FluentValidation" Version="1.7.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FormKit.FluentValidation" Version="1.7.0" />
<PackageReference Include="FormKit.FluentValidation" />
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 FormKit.FluentValidation --version 1.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FormKit.FluentValidation, 1.7.0"
#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 FormKit.FluentValidation@1.7.0
#: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=FormKit.FluentValidation&version=1.7.0
#tool nuget:?package=FormKit.FluentValidation&version=1.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FormKit
A lightweight, fluent form builder for Blazor that generates accessible EditForm markup, validation wiring, and field components from a strongly-typed model. Renderer-agnostic: the same fluent definition works with plain HTML, MudBlazor, or FluentUI via swappable renderers.
Quickstart
1. Install
dotnet add package FormKit
dotnet add package FormKit.Renderers.Html
2. Register services
builder.Services.AddFormKit()
.UseHtmlRenderer();
3. Define and render a form
@page "/customers/new"
@using FormKit
<FormKitForm TModel="CustomerVm"
Definition="@_form"
Model="@_model"
OnValidSubmit="HandleSubmit" />
@code {
private CustomerVm _model = new();
private readonly FormDefinition<CustomerVm> _form = FormBuilder.For<CustomerVm>()
.Field(x => x.Name).Required().MaxLength(120)
.Field(x => x.Email).Required()
.Field(x => x.IsCompany).Label("Is a company")
.Field(x => x.CompanyName)
.When(m => m.IsCompany)
.Required()
.Group("Address", g => g
.Field(x => x.Address.Street).Required()
.Field(x => x.Address.City).Required()
.Field(x => x.Address.Country).Select<Country>())
.Build();
private Task HandleSubmit(EditContext context) => _service.CreateAsync(_model);
}
Features
- Fluent API — describe forms from POCO models in a few lines
- Accessible by default — correct
label/forassociation,aria-required,aria-invalid,aria-describedby,role="alert"error regions - Conditional fields —
.When(m => m.IsCompany)shows/hides fields based on model state - Multi-step forms —
.Step("Customer", ...)with per-step validation - Field groups —
.Group("Address", ...)renders as<fieldset>with<legend> - DataAnnotations validation — built-in via
EditFormandDataAnnotationsValidator - Pluggable renderers — swap UI libraries without rewriting form definitions
- Trimming & AOT friendly — annotated with
IsTrimmable=true
Supported Field Types
| Type | Auto-detected from | HTML input |
|---|---|---|
| Text | string |
<input type="text"> |
| Number | int, long, short, byte |
<input type="number"> |
| Decimal | decimal, double, float |
<input type="number" step="any"> |
| Checkbox | bool |
<input type="checkbox"> |
| Date | DateOnly |
<input type="date"> |
| DateTime | DateTime, DateTimeOffset |
<input type="datetime-local"> |
| Time | TimeOnly, TimeSpan |
<input type="time"> |
| Select | via .Select<T>() / .Options(...) |
<select> |
| RadioGroup | via .RadioGroup<T>() / .RadioGroup(...) |
radio inputs |
| MultiSelect | via .MultiSelect<T>() / .MultiSelect(...) |
<select multiple> |
| FileUpload | via .File(accept?) |
<InputFile> (binds IBrowserFile) |
| Collection | via .Collection(x => x.List, item => …) |
repeating <fieldset> per item + add/remove |
| MultilineText | via .Type(FieldType.MultilineText) |
<textarea> |
| Hidden | via .Type(FieldType.Hidden) |
<input type="hidden"> |
Architecture
| Package | Purpose |
|---|---|
FormKit.Abstractions |
Interfaces (IFormRenderer, IFieldDescriptor, IValidationAdapter) |
FormKit |
Fluent builder, validation orchestration, FormKitForm component |
FormKit.Renderers.Html |
Plain HTML renderer (zero-dependency, accessible) |
FormKit.Renderers.FluentUI |
Microsoft Fluent UI Blazor renderer (.UseFluentUIRenderer()) |
FormKit.FluentValidation |
FluentValidation adapter (FormKitForm.Validator) |
A live demo (Blazor WebAssembly, with an HTML/FluentUI renderer toggle) is published to GitHub Pages: https://agriffard.github.io/FormKit/.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.
-
net10.0
- FluentValidation (>= 12.1.1)
- FormKit (>= 1.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.