Beispiel #1
0
        internal static IStringAssertion DoesNotEndWith(this StringAssertion source, string text)
        {
            source.Extend(x => AssertResult.New(!x.EndsWith(text, StringComparison.CurrentCultureIgnoreCase),
                                                Resources.DoesNotEndWith, text));

            return(source);
        }
Beispiel #2
0
 internal static StringAssertion DoesNotContainDigit(this StringAssertion source)
 {
     source.Extend(x =>
     {
         bool isValid = Regex.IsMatch(x, @"\d");
         return(AssertResult.New(!isValid, Resources.DoesNotContainDigit));
     });
     return(source);
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        internal static IStringAssertion DoesNotContain(this StringAssertion source, string text)
        {
            source.Extend(x => AssertResult.New(!x.Contains(text), Resources.DoesNotContain, text));

            return(source);
        }
Beispiel #5
0
 internal static StringAssertion IsLongerThan(this StringAssertion source, int length)
 {
     source.Extend(x => AssertResult.New(x.Length > length, Resources.IsLongerThan, length + 1));
     return(source);
 }
Beispiel #6
0
 internal static StringAssertion IsEmptyOrWhitespace(this StringAssertion source)
 {
     source.Extend(x => AssertResult.New(string.IsNullOrWhiteSpace(x), Resources.IsEmpty));
     return(source);
 }
Beispiel #7
0
 internal static StringAssertion IsEmpty(this StringAssertion source)
 {
     source.Extend(x => AssertResult.New(x.Length <= 0, Resources.IsEmpty));
     return(source);
 }