internal static IStringAssertion DoesNotEndWith(this StringAssertion source, string text) { source.Extend(x => AssertResult.New(!x.EndsWith(text, StringComparison.CurrentCultureIgnoreCase), Resources.DoesNotEndWith, text)); return(source); }
internal static StringAssertion DoesNotContainDigit(this StringAssertion source) { source.Extend(x => { bool isValid = Regex.IsMatch(x, @"\d"); return(AssertResult.New(!isValid, Resources.DoesNotContainDigit)); }); return(source); }
internal static StringAssertion IsNotValidEmail(this StringAssertion source) { source.Extend(x => { //bool isEmail = Regex.IsMatch(x, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"); RegexHelper helper = new RegexHelper(); var isEmail = helper.IsValidEmail(x); return(AssertResult.New(string.IsNullOrWhiteSpace(x) || !isEmail, Resources.IsNotValidEmail)); }); return(source); }
internal static IStringAssertion DoesNotContain(this StringAssertion source, string text) { source.Extend(x => AssertResult.New(!x.Contains(text), Resources.DoesNotContain, text)); return(source); }
internal static StringAssertion IsLongerThan(this StringAssertion source, int length) { source.Extend(x => AssertResult.New(x.Length > length, Resources.IsLongerThan, length + 1)); return(source); }
internal static StringAssertion IsEmptyOrWhitespace(this StringAssertion source) { source.Extend(x => AssertResult.New(string.IsNullOrWhiteSpace(x), Resources.IsEmpty)); return(source); }
internal static StringAssertion IsEmpty(this StringAssertion source) { source.Extend(x => AssertResult.New(x.Length <= 0, Resources.IsEmpty)); return(source); }