This project has moved. For the latest updates, please go here.

Built-in argument assessments reference

Is.NotNull

Purpose: to validate reference type argument against null.
Applicable to: any reference type
Exception types:
  • ArgumentNullException when argument value is null.
Examples
  • This assessment can be used in a fluent syntax
public static void IsNotNullExample(object arg)
{
    Guard.Argument(() => arg, Is.NotNull /*, ... Any other assessment */);
    // ...
}
  • This assessment can be used in a dedicated syntax with particular error message
public static void IsNotNullExample(object arg)
{
    Guard.Argument(() => arg, Is.NotNull, "Provided arg should not be null");
    // ...
}

Is.NotNullOrEmpty

Purpose: to validate string argument against null and empty value.
Applicable to: string
Exception types:
  • ArgumentNullException when argument value is null.
  • ArgumentOutOfRangeException when argument value is empty.
Examples
  • This assessment can be used in a fluent syntax
public static void IsNotNullOrEmptyExample(string arg)
{
    Guard.Argument(() => arg, Is.NotNullOrEmpty /*, ... Any other assessment */);
    // ...
}
  • This assessment can be used in a dedicated syntax with particular error message
public static void IsNotNullOrEmptyExample(string arg)
{
    Guard.Argument(() => arg, Is.NotNullOrEmpty, "Provided arg should not be null or empty");
    // ...
}

Is.NotNullOrWhiteSpace

Purpose: to validate string argument against null, empty and white space values.
Applicable to: string
Exception types:
  • ArgumentNullException when argument value is null.
  • ArgumentOutOfRangeException when argument value is empty or white space.
Examples
  • This assessment can be used in a fluent syntax
public static void IsNotNullOrWhiteSpaceExample(string arg)
{
    Guard.Argument(() => arg, Is.NotNullOrWhiteSpace /*, ... Any other assessment */);
    // ...
}
  • This assessment can be used in a dedicated syntax with particular error message
public static void IsNotNullOrWhiteSpaceExample(string arg)
{
    Guard.Argument(() => arg, Is.NotNullOrWhiteSpace, "Provided arg should not be null, empty or white space");
    // ...
}

Last edited Oct 16, 2014 at 12:30 AM by Wombatush, version 2