Koto.Validation
0.5.0-preview.1
See the version list below for details.
dotnet add package Koto.Validation --version 0.5.0-preview.1
NuGet\Install-Package Koto.Validation -Version 0.5.0-preview.1
<PackageReference Include="Koto.Validation" Version="0.5.0-preview.1" />
<PackageVersion Include="Koto.Validation" Version="0.5.0-preview.1" />
<PackageReference Include="Koto.Validation" />
paket add Koto.Validation --version 0.5.0-preview.1
#r "nuget: Koto.Validation, 0.5.0-preview.1"
#:package Koto.Validation@0.5.0-preview.1
#addin nuget:?package=Koto.Validation&version=0.5.0-preview.1&prerelease
#tool nuget:?package=Koto.Validation&version=0.5.0-preview.1&prerelease
Koto.Validation
FluentValidation extensions and the validation pipeline behavior for the Koto suite.
Uses FluentValidation v12 (Apache 2.0 on all versions), pinned to
[12.0.0,13.0.0).
Install
dotnet add package Koto.Validation
What's included
| Type | Purpose |
|---|---|
KotoValidators.MustBeValueObject<T, TSource, TValueObject> |
Validates a property by calling a domain factory (Func<TSource, Result<TVO>>) — any source type |
KotoValidators.ListMustContainNumberOfItems |
Min/max count rule with Errors.General.CollectionIsTooSmall/Large |
ValidationBehavior<TRequest, TResponse> |
Runs all validators for the request sequentially before the handler |
ValidationRuleFailed |
The error for rules not backed by a domain factory (validation.rule.failed, details.rule = the rule's code) |
AddValidationBehavior() |
Puts the behavior at an explicit position in KotoApplicationOptions |
AddKotoValidation(assemblies) |
Scans IValidator<T> implementations (registers the behavior if it was not added through the options) |
Register
builder.Services.AddKotoApplication(
o => o.AddLoggingBehavior().AddValidationBehavior().AddTransactionBehavior(), // Logging → Validation → Transaction
typeof(PlaceOrderHandler).Assembly);
builder.Services.AddKotoValidation(typeof(PlaceOrderValidator).Assembly);
With this order a validation failure never opens a transaction. Calling AddKotoValidation alone
still works — the behavior is then appended after the behaviors configured in the options.
Write a validator — one source of truth
The validation logic lives in the domain factory; the validator only calls it:
public sealed class PlaceOrderValidator : AbstractValidator<PlaceOrderCommand>
{
public PlaceOrderValidator()
{
RuleFor(x => x.Email).MustBeValueObject(Email.Create); // string source
RuleFor(x => x.Quantity).MustBeValueObject(Quantity.Create); // int source — any type works
RuleFor(x => x.Items).ListMustContainNumberOfItems(1, 100);
RuleFor(x => x.CustomerId).NotEmpty(); // plain FluentValidation rule
}
}
Validators are keyed by the concrete command type and discovered by the pipeline automatically.
What the handler never sees, and what the client gets
On failure the behavior returns an AppResult carrying one EnrichedError per failure, each
bound to its field:
- a
MustBeValueObjectfailure keeps the domain error —general.value.is-required,identity.email.invalid, … — with its record properties asdetails; - any other rule (
NotEmpty(),Length(),MustAsync()) becomesvalidation.rule.failedwithdetails.ruleset to the rule's error code (NotEmptyValidatoror yourWithErrorCodevalue).
Nothing is collapsed into a string; the API layer renders every error inside the response envelope.
Validators run one after another, so async rules may share scoped services such as a DbContext.
Upgrading from 0.4
0.5 adds AddValidationBehavior() to position the behavior explicitly, removes MustBeEntity, NotEmptyWithKotoError and LengthWithKotoError, runs validators sequentially, and reports plain rules as validation.rule.failed (details.rule) instead of the FluentValidation error code. The step-by-step guide for the whole suite, with before/after code, is
docs/migrations/0.4-to-0.5.md.
| 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. |
-
net10.0
- FluentValidation (>= 12.0.0 && < 13.0.0)
- Koto.Application (>= 0.5.0-preview.1)
- Koto.Domain (>= 0.5.0-preview.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Koto.Validation:
| Package | Downloads |
|---|---|
|
Koto.Api.FastEndpoints
FastEndpoints integration for Koto: CQRS base endpoints responding with the Koto Envelope, binding errors in the same envelope, correlation ID middleware, and global exception handler. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.0-preview.9 | 50 | 11/30/2026 |
| 0.5.0-preview.8 | 60 | 11/30/2026 |
| 0.5.0-preview.7 | 57 | 11/29/2026 |
| 0.5.0-preview.6 | 49 | 11/29/2026 |
| 0.5.0-preview.5 | 56 | 11/29/2026 |
| 0.5.0-preview.4 | 56 | 11/29/2026 |
| 0.5.0-preview.3 | 51 | 11/29/2026 |
| 0.5.0-preview.2 | 59 | 11/29/2026 |
| 0.5.0-preview.1 | 64 | 11/8/2026 |
| 0.4.0 | 177 | 7/21/2026 |
| 0.3.0-preview.15 | 83 | 7/21/2026 |
| 0.3.0-preview.14 | 85 | 7/21/2026 |
| 0.3.0-preview.13 | 83 | 7/21/2026 |
| 0.3.0-preview.12 | 75 | 7/21/2026 |
| 0.3.0-preview.11 | 76 | 7/21/2026 |
| 0.3.0-preview.10 | 77 | 7/21/2026 |
| 0.3.0-preview.9 | 88 | 7/21/2026 |
| 0.3.0-preview.8 | 79 | 7/21/2026 |
| 0.3.0-preview.7 | 89 | 7/21/2026 |
| 0.3.0-preview.6 | 85 | 7/20/2026 |
0.5.0-preview.1 — new error model: abstract Error catalog, AppResult for handlers, one Envelope response for every transport (ADR-026). Breaking for 0.4 consumers; migration guide: https://github.com/arigatory/Koto/blob/main/docs/migrations/0.4-to-0.5.md