Skip to content

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

License

Notifications You must be signed in to change notification settings

eric-davis/ArgSentry

Repository files navigation

ArgSentry

Nuget Nuget

Build status codecov

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

License

Stars

Watchers

Forks

Packages

No packages published

Languages