Fudie.Validation 1.0.12

dotnet add package Fudie.Validation --version 1.0.12
                    
NuGet\Install-Package Fudie.Validation -Version 1.0.12
                    
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="Fudie.Validation" Version="1.0.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fudie.Validation" Version="1.0.12" />
                    
Directory.Packages.props
<PackageReference Include="Fudie.Validation" />
                    
Project file
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 Fudie.Validation --version 1.0.12
                    
#r "nuget: Fudie.Validation, 1.0.12"
                    
#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 Fudie.Validation@1.0.12
                    
#: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=Fudie.Validation&version=1.0.12
                    
Install as a Cake Addin
#tool nuget:?package=Fudie.Validation&version=1.0.12
                    
Install as a Cake Tool

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

  • FluentValidation
  • Fudie.Domain
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
1.0.12 132 3/8/2026
1.0.11 116 3/7/2026
1.0.10 124 3/5/2026
1.0.9 125 3/5/2026
1.0.8 118 3/5/2026
1.0.7 131 3/4/2026
1.0.6 124 3/4/2026
1.0.5 119 3/4/2026
1.0.4 133 3/3/2026
1.0.3 130 3/3/2026
1.0.2 119 3/3/2026
1.0.1 127 3/2/2026
1.0.0 118 3/2/2026