public static GuardsContext <string> NotEqual(this GuardsContext <string> guardsContext, string toCompare) { if (guardsContext.Value == toCompare) { throw new ArgumentException($"String [{guardsContext.Value}] of name [{guardsContext.Name}] cannot be equal [{toCompare}]!"); } return(guardsContext); }
public static GuardsContext <string> NotNull(this GuardsContext <string> guardsContext) { if (guardsContext.Value == null) { throw new ArgumentException($"String [{guardsContext.Name}] cannot be null!"); } return(guardsContext); }
public static GuardsContext <string> NotEmpty(this GuardsContext <string> guardsContext) { if (guardsContext.Value == string.Empty) { throw new ArgumentException($"String [{guardsContext.Name}] cannot be empty!"); } return(guardsContext); }
public static GuardsContext <string> NotWhitespace(this GuardsContext <string> guardsContext) { if (guardsContext.Value != null && string.IsNullOrWhiteSpace(guardsContext.Value)) { throw new ArgumentException($"String [{guardsContext.Name}] cannot be whitespace!"); } return(guardsContext); }
public static GuardsContext <int> NotZero(this GuardsContext <int> guardsContext) { if (guardsContext.Value == 0) { throw new ArgumentException($"Int [{guardsContext.Value}] of name [{guardsContext.Name}] cannot be zero!"); } return(guardsContext); }
public static GuardsContext <int> NotInRange(this GuardsContext <int> guardsContext, int min, int max) { if (guardsContext.Value >= min && guardsContext.Value <= max) { throw new ArgumentException($"Int [{guardsContext.Value}] of name [{guardsContext.Name}] cannot be in range: [{min}] to [{max}]!"); } return(guardsContext); }
public static GuardsContext <int> InRange(this GuardsContext <int> guardsContext, int min, int max) { if (guardsContext.Value < min || guardsContext.Value > max) { throw new ArgumentException($"Int [{guardsContext.Value}] of name [{guardsContext.Name}] has to be in range: [{min}] to [{max}]!"); } return(guardsContext); }
public static GuardsContext <int> Equal(this GuardsContext <int> guardsContext, int toCompare) { if (guardsContext.Value != toCompare) { throw new ArgumentException($"Int [{guardsContext.Value}] of name [{guardsContext.Name}] has to be equal [{toCompare}]!"); } return(guardsContext); }
public static GuardsContext <int> NotPositive(this GuardsContext <int> guardsContext) { if (guardsContext.Value > 0) { throw new ArgumentException($"Int [{guardsContext.Value}] of name [{guardsContext.Name}] cannot be positive!"); } return(guardsContext); }