OrionGuard 3.0.0

dotnet add package OrionGuard --version 3.0.0
                    
NuGet\Install-Package OrionGuard -Version 3.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="OrionGuard" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OrionGuard" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OrionGuard" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OrionGuard --version 3.0.0
                    
#r "nuget: OrionGuard, 3.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.
#:package OrionGuard@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OrionGuard&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OrionGuard&version=3.0.0
                    
Install as a Cake Tool

OrionGuard

OrionGuard is a lightweight and extensible library for guarding your application's parameters, ensuring input validation, and throwing meaningful exceptions. This library is ideal for developers who want to improve code quality and enforce input validation consistently.


Features

  • 🛡️ Guard Clauses for common scenarios:
    • Null and Empty String Validation
    • Range Checks for Numeric Values
    • Enum Value Validation
    • Regex Pattern Matching
    • Date Validation (Future/Past Dates)
    • Email Address Validation
  • 🚀 Easy to use and highly extensible.
  • ✅ Fully unit-tested and ready for production.

Installation

OrionGuard is available as a NuGet package. You can install it using the .NET CLI or Package Manager in Visual Studio.

Using .NET CLI

dotnet add package OrionGuard

Using Package Manager

Install-Package OrionGuard

Getting Started

  1. Null Check

Guard.AgainstNull(testObject, nameof(testObject)); // Throws NullValueException if testObject is null.

  1. Range Check

Guard.AgainstOutOfRange(5, 1, 10, nameof(value)); // Throws OutOfRangeException if value is outside the range.

  1. Regex Validation

"abc123".AgainstRegexMismatch(@"^\d+$", nameof(value)); // Throws RegexMismatchException if value does not match the pattern.

  1. Email Validation

"example.com".AgainstInvalidEmail(nameof(email)); // Throws InvalidEmailException if the email is invalid.

Extensibility

You can define custom guard clauses by implementing the IGuardClause interface:

public class MyCustomGuard : IGuardClause { public void Validate() { // Custom validation logic } }

Contributing

We welcome contributions! To contribute:

Fork the repository on GitHub.
Create a new branch for your feature or bug fix.
Submit a pull request.

License

OrionGuard is licensed under the MIT License. You are free to use, modify, and distribute this library under the terms of the license.

Support

If you encounter any issues or have questions, please visit the GitHub Issues page or contact us at tunahan.ali.ozturk@outlook.com.

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