vali-flow
1.0.1
See the version list below for details.
dotnet add package vali-flow --version 1.0.1
NuGet\Install-Package vali-flow -Version 1.0.1
<PackageReference Include="vali-flow" Version="1.0.1" />
<PackageVersion Include="vali-flow" Version="1.0.1" />
<PackageReference Include="vali-flow" />
paket add vali-flow --version 1.0.1
#r "nuget: vali-flow, 1.0.1"
#addin nuget:?package=vali-flow&version=1.0.1
#tool nuget:?package=vali-flow&version=1.0.1
ValiFlow - Fluent Validation for .NET
Introduction 🚀
ValiFlow is a fluent validation library for .NET that allows you to define validation rules in a readable and structured way. It supports various data types and provides methods to validate collections, numbers, dates, and strings efficiently.
Installation 📦
To install ValiFlow via NuGet, run the following command:
dotnet add package vali-flow
Usage 🛠️
Basic Example
var validator = new ValiFlow<Product>()
.NotNull(p => p.Name)
.GreaterThan(p => p.Price, 0)
.IsToday(p => p.CreatedAt);
bool result = validator.Evaluate(product);
Methods Overview 📝
Evaluate
✅
Validates a single entity based on the defined rules.
var validator = new ValiFlow<Product>()
.NotNull(p => p.Name)
.GreaterThan(p => p.Price, 0);
bool isValid = validator.Evaluate(product);
EvaluateAll
🔄
Validates multiple entities at once and returns a dictionary with validation results.
var products = new List<Product> { product1, product2, product3 };
var validator = new ValiFlow<Product>()
.NotNull(p => p.Name)
.GreaterThan(p => p.Price, 0);
var results = validator.EvaluateAll(products);
Build
🏗️
It creates the whole set of expressions to use at our convenience, either filtering in linq or with EF.
var validator = new ValiFlow<Product>()
.NotNull(p => p.Name)
.GreaterThan(p => p.Price, 0);
Expression<Func<Product, bool>> isValid = validator..Build();
Comparison: Without vs. With ValiFlow ⚖️
Without ValiFlow (Manual Validation)
if (string.IsNullOrEmpty(product.Name)) throw new Exception("Name cannot be null");
if (product.Price <= 0) throw new Exception("Price must be greater than 0");
if (product.CreatedAt.Date != DateTime.Today) throw new Exception("Invalid creation date");
With ValiFlow (Fluent Validation)
var validator = new ValiFlow<Product>()
.NotNull(p => p.Name)
.GreaterThan(p => p.Price, 0)
.IsToday(p => p.CreatedAt);
bool result = validator.Evaluate(product);
News
- New Method for string that allows to filter a n number of properties based on a value
- Improved AddSubGroup() validation
Donations 💖
If you find ValiFlow useful and would like to support its development, consider making a donation:
- For Latin America: Donate via MercadoPago
- For International Donations: Donate via PayPal
Your contributions help keep this project alive and improve its development! 🚀
License 📜
This project is licensed under the Apache License 2.0.
Contributions 🤝
Feel free to open issues and submit pull requests to improve this library!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
-New Method for string that allows to filter a n number of properties based on a value.
-Improved AddSubGroup() validation.