Ensure.That 7.1.0

Argument validation made simple and unified. It ensures arguments conforms to simple validation rules and provides an uniformed exception throwing strategy if arguments are invalid.

Install-Package Ensure.That -Version 7.1.0
dotnet add package Ensure.That --version 7.1.0
paket add Ensure.That --version 7.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Using contextual validation

This flavour was introduced in the v7.0.0 release.

Ensure.String.IsNotNullOrWhiteSpace(myString);
Ensure.String.IsNotNullOrWhiteSpace(myString, nameof(myArg));

the value is passed through so that you e.g. can assign it to a field:

_field1 = Ensure.String.IsNotNullOrWhiteSpace(myString);
_field2 = Ensure.String.IsNotNullOrWhiteSpace(myString, nameof(myArg));

Using static simple methods

The EnsureArg flavour was added in the v5.0.0 release.

EnsureArg.IsNotNullOrWhiteSpace(myString);
EnsureArg.IsNotNullOrWhiteSpace(myString, nameof(myArg));

the value is passed through so that you e.g. can assign it to a field:

_field1 = EnsureArg.IsNotNullOrWhiteSpace(myString);
_field2 = EnsureArg.IsNotNullOrWhiteSpace(myString, nameof(myArg));

Turn On/Off - default is On

Could be used with different profiles. Like Debug and CI is On while Release is Off.

#if RELEASE
    Ensure.Off()
#endif

Using contextual validation

This flavour was introduced in the v7.0.0 release.

Ensure.String.IsNotNullOrWhiteSpace(myString);
Ensure.String.IsNotNullOrWhiteSpace(myString, nameof(myArg));

the value is passed through so that you e.g. can assign it to a field:

_field1 = Ensure.String.IsNotNullOrWhiteSpace(myString);
_field2 = Ensure.String.IsNotNullOrWhiteSpace(myString, nameof(myArg));

Using static simple methods

The EnsureArg flavour was added in the v5.0.0 release.

EnsureArg.IsNotNullOrWhiteSpace(myString);
EnsureArg.IsNotNullOrWhiteSpace(myString, nameof(myArg));

the value is passed through so that you e.g. can assign it to a field:

_field1 = EnsureArg.IsNotNullOrWhiteSpace(myString);
_field2 = EnsureArg.IsNotNullOrWhiteSpace(myString, nameof(myArg));

Turn On/Off - default is On

Could be used with different profiles. Like Debug and CI is On while Release is Off.

#if RELEASE
    Ensure.Off()
#endif

Release Notes

https://github.com/danielwertheim/ensure.that/blob/master/ReleaseNotes.md

  • .NETFramework 4.5.1

    • No dependencies.
  • .NETStandard 1.1

  • .NETStandard 2.0

    • No dependencies.

Version History

Version Downloads Last updated
7.1.0 (current version) 77 11/19/2017
7.1.0-pre50 35 11/15/2017
7.0.0 303 11/9/2017
7.0.0-pre43 33 11/9/2017
7.0.0-pre38 33 11/9/2017
7.0.0-pre37 45 10/31/2017
7.0.0-pre32 251 10/16/2017
7.0.0-pre24 97 9/27/2017
6.0.1 1,567 10/4/2017
6.0.1-pre28 40 10/3/2017
6.0.0 1,816 9/19/2017
6.0.0-pre18 45 9/14/2017
6.0.0-pre16 57 9/10/2017
6.0.0-pre15 42 9/10/2017
6.0.0-pre12 41 9/9/2017
6.0.0-pre11 52 9/7/2017
5.0.0 57,689 10/8/2016
5.0.0-b3 132 10/5/2016
4.0.0 35,066 11/24/2015
3.3.0 1,071 11/10/2015
3.2.0 1,498 9/28/2015
3.1.1 590 9/19/2015
3.1.0 1,579 8/30/2015
3.0.0 891 8/22/2015
2.0.0 22,965 7/2/2014
1.0.0 3,615 7/10/2013