Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.
eric-davisPublic archive

About

ArgSentry is a .NET / .NET Core utility library for validating method argument values.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

ArgSentry

Nuget Nuget

⚠️ Archived — no longer maintained. Most of what Prevent does is now built into .NET itself (ArgumentNullException.ThrowIfNull, ArgumentException.ThrowIfNullOrEmpty, ArgumentOutOfRangeException.ThrowIfGreaterThan, etc., .NET 6/8+). For the rest (collection/Guid/default-value checks), see Ardalis.GuardClauses, which is actively maintained. This package will remain on NuGet as-is for existing consumers, but there will be no further updates, bug fixes, or releases.

ArgSentry is a .NET / .NET Core utility library for validating method argument values.

/// <summary>
/// Does something useless...but safely.
/// </summary>
/// <param name="nonNullObj">A required, non-null object.</param>
/// <param name="positiveNumber">A positive number.</param>
/// <param name="requiredString">A required, non-null, non-empty, non-white space string.</param>
/// <param name="nonEmptyList">A required non-null, non-empty collection.</param>
/// <param name="nonEmptyGuid">A non-empty GUID.</param>
/// <returns></returns>
public bool DoSomething(
    object nonNullObj, 
    int positiveNumber, 
    string requiredString, 
    List<string> nonEmptyList, 
    Guid nonEmptyGuid)
{
    Prevent.NullObject(nonNullObj, nameof(nonNullObj));
    Prevent.ValueLessThanOrEqualTo(positiveNumber, 0, nameof(positiveNumber));
    Prevent.NullOrWhiteSpaceString(requiredString, nameof(requiredString));
    Prevent.NullOrEmptyCollection(nonEmptyList, nameof(nonEmptyList));
    Prevent.EmptyGuid(nonEmptyGuid, nameof(nonEmptyGuid));

    return true;
}

About

ArgSentry is a .NET / .NET Core utility library for validating method argument values.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages