Skip to content

Guard

Argument validation utility class following the fail-fast principle.

API Reference

MethodDescription
NotNull<T>(T? value)Throws ArgumentNullException if null
NotNullOrEmpty(string?)Throws if string is null or empty
NotNullOrWhiteSpace(string?)Throws if string has no content
GreaterThan<T>(T, T min)Throws if value <= min
LessThan<T>(T, T max)Throws if value >= max
InRange<T>(T, T min, T max)Throws if outside range
Positive<T>(T)Throws if value <= 0
NotNegative<T>(T)Throws if value < 0
NotEmpty(Guid)Throws if Guid.Empty
ValidEmail(string?)Throws if invalid email format
MaxLength(string?, int)Throws if exceeds length
MinLength(string?, int)Throws if below length
DefinedEnum<TEnum>(TEnum)Throws if enum not defined
Ensure(bool, string)Throws if condition false

Released under the MIT License.