public static GuardThis <string> AgainstNullOrEmpty(this GuardThis <string> guard, string errorMessage) { return(guard.WithRule(val => !string.IsNullOrEmpty(val), errorMessage)); }
public static GuardThis <string> AgainstNonIpAddressFormat(this GuardThis <string> guard, string errorMessage) { var match = Regex.Match(guard.Obj, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"); return(guard.WithRule(val => val.ToLowerInvariant() == "localhost" || match.Success, errorMessage)); }