Sanctify 1.0.0

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

// Install Sanctify as a Cake Tool
#tool nuget:?package=Sanctify&version=1.0.0                

Sanctify

Sanctify is a lightweight library for implementing guard clauses in .NET applications. It provides a clean, expressive API to validate method arguments and protect your code from invalid inputs.


Features

  • Null Checks: Validate that arguments are not null.
  • Whitespace Checks: Ensure strings are not null, empty, or whitespace.
  • Range Checks: Validate numbers, dates, and other comparable types.
  • Custom Exceptions: Specify custom exceptions to throw for invalid inputs.

Installation

Install Sanctify via NuGet:

Install-Package Sanctify

Or using the .NET CLI:

dotnet add package Sanctify

Usage Examples

Basic Guard Clauses

Null or Whitespace
string input = " ";

Guard.Against().NullOrWhiteSpace(input, "Input cannot be null or empty");
Custom Exception
string input = null;

Guard.Against(
    "InputValue",
    () => new MyCustomException("InputValue", "Value cannot be null")
).Null(input);
Range Checks
int value = 15;

Guard.Against().LessThan(value, 10, "Value must be at least 10.");
Guard.Against().GreaterThan(value, 20, "Value must not exceed 20.");

Contributing

Contributions are welcome! If you find a bug, have a feature request, or want to contribute code, feel free to submit an issue or a pull request on GitHub.


License

This project is licensed under the MIT License.


Contact

For questions or feedback, please reach out via GitHub issues or discussions.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 53 1/18/2025