Qowaiv.Validation.Guarding
2.2.0
dotnet add package Qowaiv.Validation.Guarding --version 2.2.0
NuGet\Install-Package Qowaiv.Validation.Guarding -Version 2.2.0
<PackageReference Include="Qowaiv.Validation.Guarding" Version="2.2.0" />
<PackageVersion Include="Qowaiv.Validation.Guarding" Version="2.2.0" />
<PackageReference Include="Qowaiv.Validation.Guarding" />
paket add Qowaiv.Validation.Guarding --version 2.2.0
#r "nuget: Qowaiv.Validation.Guarding, 2.2.0"
#:package Qowaiv.Validation.Guarding@2.2.0
#addin nuget:?package=Qowaiv.Validation.Guarding&version=2.2.0
#tool nuget:?package=Qowaiv.Validation.Guarding&version=2.2.0
Qowaiv Validation Guarding
Fluent pre-condition guards for domain logic. Uses the .Must() extension
method to create guard expressions that return Result<T> to communicate
the outcome.
Must
The .Must() extension creates a Must<TSubject> guard builder on any object.
Be / NotBe
Guard that a condition is true or false:
Result<Game> result = game.Must().Be(
game.Phase == GamePhase.Started,
"Game must be started");
Result<Game> result = game.Must().NotBe(
game.Phase == GamePhase.Finished,
"Game must not be finished");
Returns a valid Result<Game> if the condition is met, otherwise an invalid
result with the specified error message.
Exist
Guard that a related entity exists by ID. Useful in command handlers:
Result<PlaceOrder> result = command.Must().Exist(
command.CustomerId,
(cmd, id) => customerRepository.Find(id));
Returns a valid result if the entity is found, otherwise an invalid result
with an EntityNotFound message.
You can also provide a custom error message:
Result<PlaceOrder> result = command.Must().Exist(
command.CustomerId,
(cmd, id) => customerRepository.Find(id),
ValidationMessage.Error("Customer not found"));
Custom guards
Extend Must<TSubject> with custom extension methods for domain-specific
guarding:
public static class MustOrderExtensions
{
public static Result<Order> MustBePlaced(this Order order)
=> order.Must().Be(
order.Status == OrderStatus.Placed,
"Order must be in Placed status");
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Qowaiv.Validation.Abstractions (>= 2.1.0)
- Qowaiv.Validation.Messages (>= 2.2.0)
-
net10.0
- Qowaiv.Validation.Abstractions (>= 2.1.0)
- Qowaiv.Validation.Messages (>= 2.2.0)
-
net8.0
- Qowaiv.Validation.Abstractions (>= 2.1.0)
- Qowaiv.Validation.Messages (>= 2.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Qowaiv.Validation.Guarding:
| Package | Downloads |
|---|---|
|
Qowaiv.DomainModel
Qowaiv implements common, universal domain objects. These types form the base of your domain model. |
|
|
Qowaiv.DomainModel.TestTools
Qowaiv implements common, universal domain objects. These types form the base of your domain model. |
GitHub repositories
This package is not used by any popular GitHub repositories.
v2.2.0
- Update dependencies.
v2.1.0
- Add notnull constraint to Result.For<T>().
v2.0.0
- Add .NET 10.0 target.
- Drop .NET9.0 targets. (BREAKING)
v1.0.0
- Add .NET 9.0 target.
- Drop .NET 5.0, NET6.0, NET7.0 targets. (BREAKING)
V0.3.1
- Fixed lacking nullable annotations. #67
v0.3.0
- Support .NET 7.0. #62
v0.2.1
- Nullable anotations. #48
v0.1.2
- Initial version
- Introduction of the Must() guarding mechanism #41.