A collection of basic guard clauses used to validate input parameters in C#.
Here is a list of the supported clauses. More clauses will be added over time. Feel free to contribute with this repository.
ThrowIfNullOrWhitespace is used to validate string values against null or whitespace values.
public SampleConstructor(string stringValue)
{
this.StringValue = stringValue.ThrowIfNullOrWhitespace(nameof(stringValue));
}
ThrowIfNull is used to validate a T
value against null.
public SampleConstructor(MyDomainModel input)
{
this.MyDomainModel = input.ThrowIfNull(nameof(input));
}