This project contains guard clauses for object, string, int, double, decimal, datetime, datetimeoffset, timespan, URL.
Guard.Against.Null(name, "Name");
Guard.Against.NullOrEmpty(name, "Name");
Guard.Against.MinimumLength(name, "Name", 10);
Guard.Against.NumberLessThan(money, "Money", 1000);
Guard.Against.NumberGreaterThanOrEqual(money, "Money", 1000);
Guard.Against.NumberNegative(money, "Money");
Guard.Against.DateTimeGreaterThan(startDate, "StartDate", DateTime.Now);
Guard.Against.InValidURL("https://nilavpatel.github.io", "URL");
- Null
- NullOrEmpty
- NullOrWhiteSpace
- LeadingAndTailingSpace
- MinimumLength
- MaximumLength
- SpecialCharacters
- Digits
- Alphabet
- LowerCase
- UpperCase
- Space
- NumberLessThan
- NumberGreaterThan
- NumberLessThanOrEqual
- NumberGreaterThanOrEqual
- NumberZero
- NumberNegative
- NumberNegativeOrZero
- NumberOutOfRange
- DateTimeLessThan
- DateTimeGreaterThan
- DateTimeLessThanOrEqual
- DateTimeGreaterThanOrEqual
- DateTimeOutOfRange
- DateTimeOffsetLessThan
- DateTimeOffsetGreaterThan
- DateTimeOffsetLessThanOrEqual
- DateTimeOffsetGreaterThanOrEqual
- DateTimeOffsetOutOfRange
- TimeSpanLessThan
- TimeSpanGreaterThan
- TimeSpanLessThanOrEqual
- TimeSpanGreaterThanOrEqual
- TimeSpanOutOfRange
- InValidURL
- InValidEmailId
- InValidGuid
- True
- False
public static class CustomGuardClause
{
public static void MoreThanMaxLimit(this IGuardClause guardClause, int argument, string argumentName)
{
if (argument > Int16.MaxValue)
{
throw new ArgumentException(string.Format("{0} is not allowing to be more than Int16 max limit", argumentName));
}
}
}