Skip to content

brijeshp1993/Guard-Pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# Guard Pattern

Guard validation clause list for object, string, int, double, decimal, datetime, timespan, URL.

Examples

Guard.AgainstNull(name, "Name");

Guard.AgainstNullOrEmpty(name, "Name");

Guard.AgainstMinimumLength(name, "Name", 10);

Guard.AgainstNumberLessThan(money, "Money", 1000);

Guard.AgainstNumberGreaterThanOrEqual(money, "Money", 1000);

Guard.AgainstNumberNegative(money, "Money");

Guard.AgainstDateTimeGreaterThan(startDate, "StartDate", DateTime.Now);

Guard.AgainstInValidURL("https://nilavpatel.github.io", "URL");

For Object

  • AgainstNull

For String

  • AgainstNullOrEmpty
  • AgainstNullOrWhiteSpace
  • AgainstLeadingAndTailingSpace
  • AgainstMinimumLength
  • AgainstMaximumLength
  • AgainstSpecialCharacters
  • AgainstDigits
  • AgainstAlphabet
  • AgainstLowerCase
  • AgainstUpperCase
  • AgainstSpace

For int, double, decimal

  • AgainstNumberLessThan
  • AgainstNumberGreaterThan
  • AgainstNumberLessThanOrEqual
  • AgainstNumberGreaterThanOrEqual
  • AgainstNumberZero
  • AgainstNumberNegative
  • AgainstNumberNegativeOrZero
  • AgainstNumberOutOfRange

For DateTime

  • AgainstDateTimeLessThan
  • AgainstDateTimeGreaterThan
  • AgainstDateTimeLessThanOrEqual
  • AgainstDateTimeGreaterThanOrEqual
  • AgainstDateTimeOutOfRange

For TimeSpan

  • AgainstTimeSpanLessThan
  • AgainstTimeSpanGreaterThan
  • AgainstTimeSpanLessThanOrEqual
  • AgainstTimeSpanGreaterThanOrEqual
  • AgainstTimeSpanOutOfRange

For Others

  • AgainstInValidURL
  • AgainstInValidEmailId
  • AgainstInValidGuid

For bool

  • AgainstTrue
  • AgainstFalse

About

Guard-Pattern validations in C#

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages