SimplySoft.ThrowValidator
1.0.0
dotnet add package SimplySoft.ThrowValidator --version 1.0.0
NuGet\Install-Package SimplySoft.ThrowValidator -Version 1.0.0
<PackageReference Include="SimplySoft.ThrowValidator" Version="1.0.0" />
<PackageVersion Include="SimplySoft.ThrowValidator" Version="1.0.0" />
<PackageReference Include="SimplySoft.ThrowValidator" />
paket add SimplySoft.ThrowValidator --version 1.0.0
#r "nuget: SimplySoft.ThrowValidator, 1.0.0"
#:package SimplySoft.ThrowValidator@1.0.0
#addin nuget:?package=SimplySoft.ThrowValidator&version=1.0.0
#tool nuget:?package=SimplySoft.ThrowValidator&version=1.0.0
Throw
Throw is a unified conditional validator designed for .NET built-in structures and types. Throw also simplifies multi-level guard conditions such as if-else and switch statements into single-line validator. Internally, Throw extends the behaviors of built-in types when its namespace is referred within current coding context.
Prerequisites
Throw requires .NET 5.0 (v5.#.#) or .NET 6.0 (v6.#.#).
Quick Demo
Throw can easily transform this 👇
int? age = 47;
if (age is null)
throw new Exception();
if (age is 0)
throw new Exception("Are you kidding?");
if (age < 0)
throw new Exception("This is unreal!");
if (age >= 13 && age <= 19)
throw new Exception("Teenagers not allowed!");
into a single minified expression like... 👇
age.Throw()
.WhenNull()
.WhenZero("Are you kidding?")
.WhenNegative("This is unreal!")
.WhenInRange(13, 19, Boundary.Inclusive, "Teenagers not allowed!");

In other words, Throw can translate imperative flow of validations into a declarative statement
Note There are more validations which can be done by
Throwwith other types as well...
Throw can easily chain multiple validations into a single in-line statement
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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 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. |
-
net5.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 |
|---|---|---|
| 1.0.0 | 424 | 8/21/2022 |