This project provides simple extension methods for handling argument validation in a fluent form.
Here's some examples of how it can be used...
public void MyMethod(object param1)
{
param1.ThrowIfNull(nameof(param1));
}
public void MyMethod(string param1)
{
param1.ThrowIfNullOrEmpty(nameof(param1));
}
It is fully fluent, returning the original object, allowing methods like this...
public int Increment(int? param1)
=> param1.ThrowIfNull(nameof(param1)) + 1;
The following fluent error checks are available along with the exceptions they can generate (depending on the value)...
- ThrowIfNull - ArgumentNullException
- ThrowIfNullOrEmpty - ArgumentNullException / ArgumentException
- ThrowIf - ArgumentException
- ThrowOutOfRangeIf - ArgumentOutOfRangeException
Welcome to The Ministry of Technology open source products. All open source Ministry of Technology products are distributed under the MIT License for maximum re-usability. Our other open source repositories can be found here...
You can download the package for this project from any of the following package managers...
If you would like to contribute to the project, please contact me.
- Keith Jackson - temporal-net@live.co.uk