Kopticx.Validify 1.0.0

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

Kopticx.Validify

NuGet .NET

Validify is a lightweight validation filter for ASP.NET Core Minimal APIs that uses FluentValidation under the hood. It allows you to inject model validation seamlessly into your API pipeline using a simple and expressive syntax.


โœจ Features

  • โœ… Declarative model validation for Minimal APIs
  • ๐Ÿ”„ Integrates with FluentValidation validators
  • ๐Ÿงฉ Plug-and-play with Microsoft.Extensions.DependencyInjection
  • ๐Ÿ›ก๏ธ Prevents invalid requests from reaching your handlers
  • ๐Ÿ“ฆ Available as a NuGet package
  • โš™๏ธ Compatible with Native AOT

๐Ÿš€ Installation

Install from NuGet:

dotnet add package Validify

โš™๏ธ How it works

Validify registers a filter that intercepts requests before they hit your endpoint. If the request model is invalid, a 400 Bad Request is returned with validation details.

Example usage:

companiesApi.MapPost("/", PostUser)
    .WithValidation<PostUserModel>();

๐Ÿ› ๏ธ Setup

1. Register the service

builder.Services.AddValidify();

2. Create a FluentValidator

public class PostUserModelValidator : AbstractValidator<PostUserModel>
{
    public PostUserModelValidator()
    {
        RuleFor(x => x.Username)
            .NotEmpty().WithMessage("Username is required")
            .MaximumLength(255).WithMessage("Must be less than 255 characters");

        // More rules...
    }
}

3. Register your FluentValidator's validators

services
    .AddSingleton<IValidator<PostUserModel>, PostUserModelValidator>()
    .AddSingleton<IValidator<PutUserModel>, PutUserModelValidator>();

๐Ÿ” Native AOT Support

Validify is fully compatible with Native AOT for optimized, self-contained executables:

<IsAotCompatible>true</IsAotCompatible>

๐Ÿงฉ Register validation response types for source generation

To support HttpValidationProblemDetails responses in AOT scenarios, include it in your JsonSerializerContext:

[JsonSerializable(typeof(HttpValidationProblemDetails))]
public partial class AppJsonSerializerContext : JsonSerializerContext;

This ensures that validation error responses can be properly serialized when using source-generated System.Text.Json.


๐Ÿ“‚ Project Structure

  • ValidifyRegistration.cs: Registers all necessary services
  • ValidationEndpointExtensions.cs: Adds .WithValidation<T>() to RouteHandlerBuilder
  • ValidationFilter.cs: The filter that runs before your endpoint logic

๐Ÿ“ฆ NuGet Package

๐Ÿ“ฆ nuget.org/packages/Kopticx.Validify


๐Ÿงช Why use Validify?

  • Prevent invalid models from hitting your business logic
  • Use FluentValidation's full feature set
  • Centralize validation behavior with clean syntax
  • Built for performance and developer experience

๐Ÿ“ License

License: MIT


๐Ÿ“„ Third-party licenses

Validify uses FluentValidation, licensed under the Apache 2.0 License.

See NOTICE file for more information.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 202 7/2/2025