FastEndpoints integration for Zeta validation framework. Provides ZetaPreProcessor and ZetaEndpoint base classes for pre-processor pipeline validation — handles both contextless and context-aware schemas.
$ dotnet add package Zeta.FastEndpointsZeta is a schema-first validation framework for .NET with a fluent, async-first API.
using Zeta;
var schema = Z.Schema<User>()
.Property(x => x.Email, s => s.Email())
.Property(x => x.Age, s => s.Min(18));
var result = await schema.ValidateAsync(new User("alice@example.com", 21));
if (!result.IsSuccess)
{
foreach (var error in result.Errors)
Console.WriteLine($"{error.PathString}: {error.Message}");
}
public sealed record User(string Email, int Age);
dotnet add package Zeta
# Optional: ASP.NET Core integration (Minimal APIs / Controllers)
dotnet add package Zeta.AspNetCore
# Optional: FastEndpoints integration
dotnet add package Zeta.FastEndpoints
using Zeta;
using Zeta.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddZeta();
var app = builder.Build();
var createUserSchema = Z.Schema<CreateUserRequest>()
.Property(x => x.Email, s => s.Email())
.Property(x => x.Name, s => s.MinLength(2));
app.MapPost("/users", (CreateUserRequest request) => Results.Ok(request))
.WithValidation(createUserSchema);
app.Run();
public sealed record CreateUserRequest(string Email, string Name);
.Using(...)var registerSchema = Z.Schema<RegisterRequest>()
.Using<RegisterContext>(async (input, sp, ct) =>
{
var repo = sp.GetRequiredService<IUserRepository>();
var exists = await repo.EmailExistsAsync(input.Email, ct);
return new RegisterContext(exists);
})
.Property(x => x.Email, s => s.Email())
.Refine((x, ctx) => !ctx.EmailExists, "Email already exists", "email_exists");
public sealed record RegisterRequest(string Email);
public sealed record RegisterContext(bool EmailExists);
.Each(...)var orderSchema = Z.Schema<CreateOrderRequest>()
.Property(x => x.Items, items => items
.Each(i => i
.Property(v => v.ProductId, s => s.NotEmpty())
.Property(v => v.Quantity, s => s.Min(1)))
.MinLength(1));
public sealed record CreateOrderRequest(List<OrderItem> Items);
public sealed record OrderItem(string ProductId, int Quantity);
This repository contains:
src/Zetasrc/Zeta.AspNetCoresrc/Zeta.FastEndpointssrc/Zeta.SourceGeneratorstestssamplesbenchmarksZeta): src/Zeta/README.mdZeta.AspNetCore): src/Zeta.AspNetCore/README.mdZeta.FastEndpoints): src/Zeta.FastEndpoints/README.mddocsZeta: Use in any .NET app (Console, Worker, Blazor, MAUI, libraries).Zeta.AspNetCore: Add only when you need ASP.NET Core integration (Minimal APIs, Controllers, validation filters).Zeta.FastEndpoints: Add when you use FastEndpoints as your web framework.dotnet build
dotnet test
# ASP.NET Core sample
dotnet run --project samples/Zeta.Sample.Api
# Blazor sample
dotnet run --project samples/Zeta.Sample.Blazor
# FastEndpoints sample
dotnet run --project samples/Zeta.Sample.FastEndpoints.Api
Comparing Zeta against FluentValidation and DataAnnotations on .NET 10 (Apple M2 Pro).
| Method | Mean | Allocated |
|---|---|---|
| FluentValidation | 131.2 ns | 600 B |
| FluentValidation (Async) | 230.1 ns | 672 B |
| Zeta | 353.2 ns | 216 B |
| Zeta (Invalid) | 442.2 ns | 1,048 B |
| DataAnnotations | 627.9 ns | 1,848 B |
| DataAnnotations (Invalid) | 990.5 ns | 2,672 B |
| FluentValidation (Invalid) | 1,923.9 ns | 7,728 B |
| FluentValidation (Invalid Async) | 2,095.5 ns | 7,800 B |
Key findings:
Run benchmarks:
dotnet run --project benchmarks/Zeta.Benchmarks -c Release
See CHANGELOG.md.