eQuantic.Validation
2.2.0
dotnet add package eQuantic.Validation --version 2.2.0
NuGet\Install-Package eQuantic.Validation -Version 2.2.0
<PackageReference Include="eQuantic.Validation" Version="2.2.0" />
<PackageVersion Include="eQuantic.Validation" Version="2.2.0" />
<PackageReference Include="eQuantic.Validation" />
paket add eQuantic.Validation --version 2.2.0
#r "nuget: eQuantic.Validation, 2.2.0"
#:package eQuantic.Validation@2.2.0
#addin nuget:?package=eQuantic.Validation&version=2.2.0
#tool nuget:?package=eQuantic.Validation&version=2.2.0
eQuantic.Validation
Framework-independent fluent validation engine for the eQuantic ecosystem.
dotnet add package eQuantic.Validation
public sealed class CreateOrderValidator : Validator<CreateOrder>
{
public CreateOrderValidator()
{
RuleFor(x => x.CustomerEmail).NotWhiteSpace().Email();
RuleFor(x => x.Total).GreaterThan(0m);
RuleFor(x => x.Installments).GreaterThanOrEqualTo(1).LessThanOrEqualTo(12);
RuleFor(x => x.Currency).NotNull().OneOf("BRL", "EUR", "USD");
RuleForEach(x => x.Items).SetValidator(new OrderItemValidator());
}
}
var result = await new CreateOrderValidator().ValidateAsync(order, cancellationToken: cancellationToken);
Use fluent rules for domain logic, cross-field pattern matching, Value Objects, and service-dependent rules. String rules (Email, MinimumLength, Matches, …) only bind to string properties, failing at compile time elsewhere. For DTOs with System.ComponentModel.DataAnnotations, instantiate or register AttributeValidator<T> to produce the same structured ValidationResult.
No subclass? Use InlineValidator
var validator = new InlineValidator<Customer>(v =>
{
v.RuleFor(x => x.Email).NotWhiteSpace().Email();
v.RuleFor(x => x.Age).InclusiveBetween(18, 120);
});
Warnings and severities
Rules can warn without blocking; IsValid ignores warnings and they stay available on the result:
RuleFor(x => x.Nickname)
.Must(n => n != "legacy", "profile.nickname.legacy")
.WithSeverity(ValidationSeverity.Warning);
var result = validator.Validate(profile);
// result.IsValid == true; result.Warnings => [ { Path: "Nickname", Code: "profile.nickname.legacy" } ]
Rules as data
Every validator implements IDescribableValidator: Describe() returns the rule manifest
(paths, kinds, codes, parameters), and ZodSchemaExporter turns it into a client-side schema:
var manifest = new CreateOrderValidator().Describe();
string ts = eQuantic.Validation.Export.ZodSchemaExporter.Export(new CreateOrderValidator());
// export const createOrderSchema = z.object({ customerEmail: z.string().min(1).email(), ... });
Async rules that don't repeat I/O
With new ValidationContext(deduplicateAsyncRules: true) (the ASP.NET Core integrations enable
this per request automatically), the same async rule for the same instance and value runs once —
composed validators, duplicated collection elements and revalidation reuse the first result.
Dependency-injection dispatching ships in this package (AddValidationDispatcher, AddValidator<TModel, TValidator> and IValidationDispatcher), so workers, gRPC services and console apps can validate without referencing ASP.NET Core — the only dependency is Microsoft.Extensions.DependencyInjection.Abstractions. OpenTelemetry instrumentation (eQuantic.Validation meter and activity source) is built in.
This package implements eQuantic.Validation.Abstractions. For web endpoints and controllers, use eQuantic.Validation.AspNetCore; for compile-time validators, accessor pre-compilation and usage diagnostics, add eQuantic.Validation.Generator.
Complete documentation: https://github.com/eQuantic/core-validation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- eQuantic.Validation.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
-
net10.0
- eQuantic.Validation.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
-
net8.0
- eQuantic.Validation.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on eQuantic.Validation:
| Package | Downloads |
|---|---|
|
eQuantic.Validation.AspNetCore
Opt-in eQuantic.Validation integration for ASP.NET Core Minimal APIs and MVC controllers. |
|
|
eQuantic.Validation.Testing
Test helpers for eQuantic.Validation: TestValidate with chainable, framework-agnostic assertions over structured failures (path, code, severity and arguments). |
GitHub repositories
This package is not used by any popular GitHub repositories.
Breaking: DI dispatching moved into the core package as AddValidationDispatcher/AddValidator, string rules are now compile-time typed.