Fudie.Validation
1.0.12
dotnet add package Fudie.Validation --version 1.0.12
NuGet\Install-Package Fudie.Validation -Version 1.0.12
<PackageReference Include="Fudie.Validation" Version="1.0.12" />
<PackageVersion Include="Fudie.Validation" Version="1.0.12" />
<PackageReference Include="Fudie.Validation" />
paket add Fudie.Validation --version 1.0.12
#r "nuget: Fudie.Validation, 1.0.12"
#:package Fudie.Validation@1.0.12
#addin nuget:?package=Fudie.Validation&version=1.0.12
#tool nuget:?package=Fudie.Validation&version=1.0.12
Fudie.Validation
Guard patterns and extension methods for validation, exception handling, result unwrapping, and entity lookup validation.
Guards
ValidationGuard
ValidationGuard.ThrowIf(name == "", "Name", "Name is required");
ValidationGuard.ThrowIfNot(age > 0, "Age", "Age must be positive");
Throws FluentValidation.ValidationException with structured errors.
All guards that throw ConflictException, UnauthorizedException, or ValidationException support an ErrorCode overload for structured error identification:
var errorCode = new ErrorCode("Customer", "Slug", "AlreadyExists", "Slug already taken", ErrorCodeCategory.Guard);
ConflictGuard.ThrowIf(slugExists, errorCode);
var nameRequired = new ErrorCode("Customer", "Name", "Required", "{PropertyName} is required");
ValidationGuard.ThrowIf(string.IsNullOrEmpty(name), nameRequired);
ErrorCode
// Category defaults to FluentValidation
var code = new ErrorCode("Customer", "Name", "Required", "{PropertyName} is required");
code.Code // "Customer.Name.Required"
// Guard category must be explicit
var guard = new ErrorCode("Customer", "IsActive", "AlreadyActive", "Already active", ErrorCodeCategory.Guard);
ErrorCodeCategory
| Value | Description |
|---|---|
FluentValidation |
UX validation rules exported to Angular (default) |
Guard |
Backend-only business rules |
NotFoundGuard
NotFoundGuard.ThrowIfNull(entity, entityId);
NotFoundGuard.ThrowIfNull<Order>(entity);
NotFoundGuard.ThrowIfNull<Order, Guid>(entity, orderId);
Throws KeyNotFoundException with formatted messages like "Order with id 'xxx' was not found".
ConflictGuard
ConflictGuard.ThrowIf(isDuplicate, "An order with this number already exists");
Throws ConflictException.
UnauthorizedGuard
UnauthorizedGuard.ThrowIf(!isOwner, "Only owners can perform this action");
Throws UnauthorizedException.
Result Extensions
Result<Order> result = CreateOrder(command);
Order order = result.ValueOrThrow(); // Throws ValidationException if failed
result.SuccessOrThrow(); // Throws ValidationException if failed (no value)
Validator Extensions
await validator.ValidateOrThrow(command);
Validates using FluentValidation and throws on failure. Also checks for empty Guids.
Public Types
| Type | Description |
|---|---|
ValidationGuard |
Condition-based validation with ThrowIf / ThrowIfNot |
NotFoundGuard |
Null-check guards throwing KeyNotFoundException |
ConflictGuard |
Conflict condition guard throwing ConflictException |
UnauthorizedGuard |
Authorization guard throwing UnauthorizedException |
ResultExtensions |
ValueOrThrow() / SuccessOrThrow() for Result<T> |
ValidatorExtensions |
ValidateOrThrow<T>() for FluentValidation validators |
ErrorCode |
Record identifying a validation error with Aggregate.Property.Rule code |
ErrorCodeCategory |
Enum: FluentValidation (UX) or Guard (backend only) |
Dependencies
FluentValidationFudie.Domain
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net8.0
- FluentValidation (>= 11.11.0)
- Fudie.Domain (>= 1.0.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Fudie.Validation:
| Package | Downloads |
|---|---|
|
Fudie
Fudie framework — all packages in one reference. Install this to get the full framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.