FlowValidate 1.1.6
dotnet add package FlowValidate --version 1.1.6
NuGet\Install-Package FlowValidate -Version 1.1.6
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="FlowValidate" Version="1.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlowValidate" Version="1.1.6" />
<PackageReference Include="FlowValidate" />
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 FlowValidate --version 1.1.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FlowValidate, 1.1.6"
#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 FlowValidate@1.1.6
#: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=FlowValidate&version=1.1.6
#tool nuget:?package=FlowValidate&version=1.1.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NuGet Package Information
| Package | Downloads | License |
|---|---|---|
Repository
You can find the source code and contribute on GitHub
FlowValidate
FlowValidate is a lightweight, fluent-style validation library for .NET.
It provides an intuitive API for validating models, making it easy to add and enforce rules while reducing boilerplate code.
Features
- Property Validation: Validate standard properties, nested objects, and collections.
- Nested & Collection Support: Automatically validates complex types and lists.
- Custom Rules: Use
Should,Must,IsNotEmpty,IsEqualor define your own logic. - Multi-error per Rule: Single property rules can produce multiple error messages.
- Reusable & Property-specific Validators: Create modular validators like
UserNameValidatorand apply them to properties. - Async / Task-based Validation: Rules can run asynchronously,
- DI Support: Easy integration with dependency injection.
- Clear Error Messages: Provides detailed validation feedback.
- Detailed Error Messages: Provides rich validation feedback with property name, attempted value, and optional error code.
- Lightweight & Fast: Optimized for high performance.
- Middleware Ready: Can validate models automatically on each request.
Installation
You can install FlowValidate via NuGet Package Manager
dotnet add package FlowValidate
Injection
var builder = WebApplication.CreateBuilder(args);
builder.Services.FlowValidationService(AssemblyReference.Assembly);
var app = builder.Build();
app.FlowValidationApp();
app.Run();
For example, we create a uservalidator
Reusable Registry Rule
public class UserNameValidator : BaseValidator<string>
{
public UserNameValidator()
{
RuleFor(name => name).IsNotEmpty().WithMessage("Name cannot be empty.")
.Length(3, 100).WithMessage("Name must be at least 3 characters.");
}
}
Nested Validator
public class UserDetailsValidator : BaseValidator<UserDetails>
{
public UserDetailsValidator()
{
RuleFor(x => x.Email).IsEmail().WithMessage("Email is invalid.");
RuleFor(x => x.Phone).MatchesRegex(@"^\d{10}$").WithMessage("Phone must be 10 digits.");
}
}
Collection Validator
public class UserBasketValidator : BaseValidator<UserBasket>
{
public UserBasketValidator()
{
RuleFor(x => x.Name).IsNotEmpty();
RuleFor(x => x.Count).IsGreaterThan(0);
}
}
Main User Validator
public class UserValidator : BaseValidator<User>
{
public UserValidator()
{
// Registry rule
ValidateRegistryRules(u => u.Name, new UserNameValidator());
// Nested validator
ValidateNested(u => u.Details, new UserDetailsValidator());
// Collection validator
ValidateCollection(u => u.Baskets, new UserBasketValidator(), item => item);
// Custom validation with Should
RuleFor(u => u.Nickname)
.Should((nickname, addError) =>
{
if (!string.IsNullOrEmpty(nickname))
{
if (nickname.Length < 3)
addError("Nickname must be at least 3 characters long.");
if (nickname.Contains(" "))
addError("Nickname cannot contain spaces.");
}
});
}
}
Using the Validator
var user = new User
{
Name = "Jo",
Age = 25,
Details = new UserDetails { Email = "invalid-email", Phone = "12345" },
Baskets = new List<UserBasket>
{
new UserBasket { Name = "", Count = 0 },
new UserBasket { Name = "Apple", Count = 3 }
}
};
var validator = new UserValidator();
var result = validator.Validate(user);
For more examples and unit tests, check the FlowValidate.Test project in the repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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.
-
net6.0
- Microsoft.AspNetCore.Http (>= 2.1.34)
- Microsoft.AspNetCore.Mvc.ApiExplorer (>= 2.1.0)
- Microsoft.AspNetCore.Routing (>= 2.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net7.0
- Microsoft.AspNetCore.Http (>= 2.1.34)
- Microsoft.AspNetCore.Mvc.ApiExplorer (>= 2.1.0)
- Microsoft.AspNetCore.Routing (>= 2.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Microsoft.AspNetCore.Http (>= 2.1.34)
- Microsoft.AspNetCore.Mvc.ApiExplorer (>= 2.1.0)
- Microsoft.AspNetCore.Routing (>= 2.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net9.0
- Microsoft.AspNetCore.Http (>= 2.1.34)
- Microsoft.AspNetCore.Mvc.ApiExplorer (>= 2.1.0)
- Microsoft.AspNetCore.Routing (>= 2.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.