Skip to content

Latest commit

 

History

History
99 lines (67 loc) · 1.05 KB

validations.md

File metadata and controls

99 lines (67 loc) · 1.05 KB

Validations

There is almost always an 'not' version

If

int myVar = 0;

ThrowOn(() => myVar)
    .If( value => value == 0);

IfNull

int? myVar = null;

ThrowOn(() => myVar)
    .IfNull();

IfDefault

int myVar = 0;

ThrowOn(() => myVar)
    .IfDefault();

IfEmpty

Works currently for

  • strings
  • IEnumerable
  • IDictionary
  • Guid
string myVar = "";

ThrowOn(() => myVar)
    .IfEmpty();

IfNullOrWhiteSpace

string myVar = "";

ThrowOn(() => myVar)
    .IfNullOrWhiteSpace();

IfEqualsTo

int myVar = 0;

ThrowOn(() => myVar)
    .IfEqualsTo(0);

IfGreaterThan

int myVar = 0;

ThrowOn(() => myVar)
    .IfGreaterThan(-1);

IfGreaterOrEqualsThan

int myVar = 0;

ThrowOn(() => myVar)
    .IfGreaterOrEqualsThan(0);

IfLowerThan

int myVar = 0;

ThrowOn(() => myVar)
    .IfLowerThan(1);

IfLowerOrEqualsThan

int myVar = 0;

ThrowOn(() => myVar)
    .IfLowerOrEqualsThan(0);