DevSource.Stack.Notifications
4.0.0
dotnet add package DevSource.Stack.Notifications --version 4.0.0
NuGet\Install-Package DevSource.Stack.Notifications -Version 4.0.0
<PackageReference Include="DevSource.Stack.Notifications" Version="4.0.0" />
<PackageVersion Include="DevSource.Stack.Notifications" Version="4.0.0" />
<PackageReference Include="DevSource.Stack.Notifications" />
paket add DevSource.Stack.Notifications --version 4.0.0
#r "nuget: DevSource.Stack.Notifications, 4.0.0"
#:package DevSource.Stack.Notifications@4.0.0
#addin nuget:?package=DevSource.Stack.Notifications&version=4.0.0
#tool nuget:?package=DevSource.Stack.Notifications&version=4.0.0
DevSource.Stack.Notifications
DevSource.Stack.Notifications is a lightweight, fluent validation library implementing the Notification Pattern. It allows you to replace exceptions with domain notifications for a cleaner, more robust error handling strategy in .NET applications.
Key Features
- Fluent API: Clean, chainable validation rules (e.g., .IsNotNullOrEmpty(...).IsEmail(...)).
- Notification Pattern: Accumulate errors instead of throwing exceptions immediately.
- No External Dependencies: Pure .NET Standard implementation.
- Comprehensive Rules: Built-in support for strings, numbers, dates, emails, passwords, files, collections, credit cards, and more.
- Brazilian Localization: Native validation for CPF, CNPJ, and Brazilian phone numbers.
Getting Started
Installation
dotnet add package DevSource.Stack.Notifications
Quick Usage
Inherit from Notifier and use ValidationRules<T> to validate your entities:
public class User : Notifier
{
public string Name { get; private set; }
public string Email { get; private set; }
public User(string name, string email)
{
Name = name;
Email = email;
// Validation Example
AddNotifications(new ValidationRules<User>()
.IsNotNullOrEmpty(nameof(Name), Name)
.MinLength(nameof(Name), Name, 3)
.IsNotNullOrEmpty(nameof(Email), Email)
.IsEmail(nameof(Email), Email)
);
}
}
Check for notifications in your service or controller:
var user = new User("John", "invalid-email");
if (user.HasNotifications)
{
foreach (var notification in user.Notifications)
{
Console.WriteLine(notification.Message);
}
}
Documentation
For full documentation, advanced usage examples (conditional validation, combining validators, ASP.NET Core integration), and contribution guidelines, please visit the GitHub Repository.
License
This project is licensed under the MIT License.
| 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
- 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.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 4.0.0 | 143 | 2/20/2026 | |
| 3.0.1 | 187 | 1/31/2026 | |
| 3.0.0 | 298 | 12/15/2025 | |
| 2.0.0 | 320 | 6/17/2025 | |
| 1.0.10 | 293 | 4/9/2025 | |
| 1.0.9 | 244 | 11/29/2024 | |
| 1.0.8 | 227 | 9/16/2024 | |
| 1.0.6 | 200 | 9/10/2024 | |
| 1.0.5 | 206 | 9/10/2024 | |
| 1.0.4 | 218 | 9/1/2024 | |
| 1.0.3 | 235 | 9/1/2024 | |
| 1.0.2 | 201 | 8/3/2024 | |
| 1.0.1 | 194 | 7/29/2024 | |
| 1.0.0 | 196 | 7/25/2024 |
### Breaking Changes
- Significant changes to method signatures and removal of deprecated methods to improve library consistency and performance. These changes may require updates in consuming applications.
- Changed validation logic for `IsBrazilianPhone`, `IsInternationalPhone`, `IsCreditCard`, `IsCpf`, `IsCnpj`, `HasValidMimeType`, `IsEmail`, and `IsPassword`. These methods now treat null or empty values as valid (optional fields) instead of invalid. To enforce required fields, chain with `IsNotNullOrEmpty` or `IsNullOrWhiteSpace`.
### Changed
- Refactored `INotifications.AddNotifications` and `Notifier.AddNotifications` to accept `INotifications` interface instead of the concrete `Notifier` class, improving dependency inversion and testability.
- Updated `ValidationRules.Join` to accept `params INotifications[]` instead of `Notifier[]`.
- Updated `Notification.Key` property to be nullable (`string?`) to correctly reflect that notifications can exist without a key.
### Fixed
- Fixed validation logic for several rules (Brazilian Documents, Credit Card, Phone, MimeType) to correctly handle empty/null values as valid (optional) unless explicitly validated as required.
- Fixed potential `NullReferenceException` in `MaxLength` and `MinLength` string validations by adding null checks.
- Fixed potential `ArgumentNullException` in `IsEmail` and `IsPassword` validations.
- Fixed `IsCreditCardNotExpired` validation logic to correctly compare dates ignoring the time component.