GuardClauses 2.1.0

dotnet add package GuardClauses --version 2.1.0                
NuGet\Install-Package GuardClauses -Version 2.1.0                
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="GuardClauses" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GuardClauses --version 2.1.0                
#r "nuget: GuardClauses, 2.1.0"                
#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.
// Install GuardClauses as a Cake Addin
#addin nuget:?package=GuardClauses&version=2.1.0

// Install GuardClauses as a Cake Tool
#tool nuget:?package=GuardClauses&version=2.1.0                

GuardClauses

GuardClause is a check of integrity preconditions used to avoid errors during execution

Get a star

If you like the library, please give a star.

Usage

public void Execution(string name, int age)
{
  Name =  GuardClause.IsZeroOrNegative(age,nameof(age));
  Age  =  GuardClause.IsNullOrEmptyStringOrWhiteSpace(name, nameof(name));
}

Available methods

GuardClause.IsZeroOrNegative(int argumentValue, string argumentName);
GuardClause.IsZeroOrNegative(decimal argumentValue, string argumentName);
GuardClause.IsZeroOrNegative(float argumentValue, string argumentName);
GuardClause.IsZeroOrNegative(long argumentValue, string argumentName);
GuardClause.IsZeroOrNegative(double argumentValue, string argumentName);
GuardClause.IsLengthExceeded(string argumentValue, string agrumentName, int maximumLength);
GuardClause.IsNullOrEmptyStringOrWhiteSpace(string argumentValue, string argumentName);
GuardClauseEnsureValidString(string argumentValue, string argumentName,List<StringValidationType> types);
GuardClauseEnsureValidString(string argumentValue, string argumentName,StringValidationType type);
GuardClause.IsNullOrEmptyString(string argumentValue, string argumentName);
GuardClause.ArgumentIsNotNull(object value, string argumentName);
GuardClause.IsZero(int argumentValue, string argumentName);
GuardClause.IsZero(long argumentValue, string argumentName);
GuardClause.IsZero(long argumentValue, string argumentName);
GuardClause.IsZero(decimal argumentValue, string argumentName);
GuardClause.IsZero(double argumentValue, string argumentName);
GuardClause.IsZero(float argumentValue, string argumentName);
GuardClause.IsNegative(int argumentValue, string argumentName);
GuardClause.IsNegative(long argumentValue, string argumentName);
GuardClause.IsNegative(long argumentValue, string argumentName);
GuardClause.IsNegative(decimal argumentValue, string argumentName);
GuardClause.IsNegative(double argumentValue, string argumentName);
GuardClause.IsNegative(float argumentValue, string argumentName);
GuardClause.DateTimeIsGraterThan(DateTime argumentValue, string argumentName ,DateTime comparableDateTme);
GuardClause.DateTimeIsLessThan(DateTime argumentValue, string argumentName ,DateTime comparableDateTme);
GuardClause.DateTimeIsOutOfRange(DateTime argumentValue,DateTime startDateTime, string argumentName ,DateTime endDateTime);
GuardClause.IsStringEmptyGuid(string argumentValue, string argumentName);
GuardClause.IsEmptyGuid(Guid argumentValue, string argumentName);
GuardClause.IsEmailValid(string email);
GuardClause.UrlChecker(string url);
GuardClause.MaximumLength(string argumentValue, string argumentName, int maximumLength);

Nuget

https://www.nuget.org/packages/GuardClauses/

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on GuardClauses:

Package Downloads
BytLabs.Domain

Package Description

BytLabs.DataAccess

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on GuardClauses:

Repository Stars
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
Version Downloads Last updated
2.1.0 59 2/5/2025
2.0.0 30 2/5/2025
1.2.4 37,802 12/7/2021
1.2.3 259 12/7/2021
1.2.2 303 11/19/2021
1.2.1 289 11/16/2021
1.2.0 290 11/15/2021
1.0.0 19,056 11/10/2021