Validation 2.4.15

Validation

Method input validation and runtime checks that report errors or throw exceptions when failures are detected.

Build status NuGet package

This project is available as the Validation NuGet package.

Basic input validation via the Requires class throws an ArgumentException.

Requires.NotNull(arg1, "arg1");
Requires.NotNullOrEmpty(arg2, "arg2");

State validation via the Verify class throws an InvalidOperationException.

Verify.Operation(condition, "some error occurred.");

Internal integrity checks via the Assumes class throws an InternalErrorException.

Assumes.True(condition, "some error");

Warning signs that should not throw exceptions via the Report class.

Report.IfNot(condition, "some error");

Code Snippets

Make writing input validation especially convenient with [code snippets][2]. Run the tools\install_snippets.cmd script within this package to copy the code snippets into your Documents\Visual Studio 201x\Code Snippets\Visual C#\My Code Snippets folder(s) and just type the first few letters of the code snippet name to get auto-completion assisted input validation.

Note that if you have Resharper installed, code snippets don't appear in auto-completion lists so you may have to press Ctrl+J after the first few letters of the code snippet name for it to become available.

Example:

private void SomeMethod(string input) {
    rnne<TAB>
}

Expands to

private void SomeMethod(string input) {
    Requires.NotNullOrEmpty(paramName, nameof(paramName));
}

And the first paramName is selected. Simply type the actual parameter name (Intellisense will auto-complete for you) and then the quoted paramName name will automatically be changed to match.

The two snippets are rnn and rnne which expand to check for null inputs or null-or-empty inputs, respectively.

Showing the top 20 packages that depend on Validation.

Packages Downloads
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET 4.5, Windows Phone 8.0 SL & 8.1 Xaml, Windows Store, Xamarin.iOS, Xamarin.Android. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation. PCLCrypto calls into each native platform's crypto API for maximum performance. For RSA operations this produces a 2-100X improvement in performance on Android and iOS over using the standard RSACryptoServiceProvider API.
64
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET, Windows Phone 8.0 & 8.1, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation. PCLCrypto calls into each native platform's crypto API for maximum performance. For RSA operations this produces a 2-100X improvement in performance on Android and iOS over using the standard RSACryptoServiceProvider API.
58
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
53
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET 4.5, Windows Phone 8.0 SL & 8.1 Xaml, Windows Store, Xamarin.iOS, Xamarin.Android. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation. PCLCrypto calls into each native platform's crypto API for maximum performance. For RSA operations this produces a 2-100X improvement in performance on Android and iOS over using the standard RSACryptoServiceProvider API.
52
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
52
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET, Windows Phone 8.0 & 8.1, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation. PCLCrypto calls into each native platform's crypto API for maximum performance. For RSA operations this produces a 2-100X improvement in performance on Android and iOS over using the standard RSACryptoServiceProvider API.
45
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
43
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
41
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
40
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET, Windows Phone, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation.
39
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET, Windows Phone, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation.
38
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
36
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET 4.5, Windows Phone 8.0 SL & 8.1 Xaml, Windows Store, Xamarin.iOS, Xamarin.Android. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation. PCLCrypto calls into each native platform's crypto API for maximum performance. For RSA operations this produces a 2-100X improvement in performance on Android and iOS over using the standard RSACryptoServiceProvider API.
32
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET, Windows Phone 8.0 & 8.1, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps. Crypto functionality includes asymmetric and symmetric encryption and signatures, and key derivation. PCLCrypto calls into each native platform's crypto API for maximum performance. For RSA operations this produces a 2-100X improvement in performance on Android and iOS over using the standard RSACryptoServiceProvider API.
31
Xunit.SkippableFact
Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.
29
PCLCrypto
PCL Crypto provides a consistent, portable set of crypto APIs for .NET, Windows Phone, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps.
29

.NET Framework 2.0

  • No dependencies.

.NET Framework 4.0

  • No dependencies.

.NET Framework 4.5

  • No dependencies.

.NET Standard 1.0

  • No dependencies.

.NET Standard 1.3

  • No dependencies.

.NETPortable 0.0

  • No dependencies.

.NETPortable 0.0

  • No dependencies.

Version Downloads Last updated
2.6.68 6 12/24/2024
2.6.65-rc.2 4 12/24/2024
2.6.55-rc.1 5 12/24/2024
2.6.13-beta 19 08/25/2023
2.6.7-beta 35 04/26/2023
2.5.51 17 08/26/2023
2.5.42 18 07/25/2023
2.5.5-beta 23 07/31/2023
2.4.22 18 08/17/2023
2.4.18 28 03/20/2023
2.4.17 29 08/31/2023
2.4.15 31 04/07/2021
2.4.15-g8377954d86 16 08/25/2023
2.4.13 30 08/28/2023
2.4.10 20 08/28/2023
2.4.9 18 06/13/2023
2.4.7 30 04/28/2023
2.3.7 28 04/26/2023
2.3.5 24 04/26/2023
2.2.8 18 06/12/2023
2.2.5 17 06/13/2023
2.2.4 10 06/12/2023
2.0.6.15003 42 07/21/2023
2.0.5.14286 23 07/26/2023
2.0.4.14103 17 08/31/2023
2.0.3.13323 32 05/09/2023
2.0.2.13022 15 02/11/2024
2.0.1.12362 17 05/06/2023
2.0.0.12319 31 04/26/2023
1.0.0.12259 12 12/04/2023