Ejemplo n.º 1
0
        public static bool IsIPLegality(string ip)
        {
            if (ValidationProvider.IsNullOrEmpty(ip))
            {
                return(false);
            }
            ip = ip.Trim();
            string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";

            return(RegexProvider.IsMatch(ip, pattern));
        }
Ejemplo n.º 2
0
        public static bool NotHasInvalidChar(string input)
        {
            if (IsNullOrEmpty(input))
            {
                return(false);
            }
            input = input.Trim();
            string pattern = "^[^<>'~`\x00b7!@#$%^&*()]+$";

            return(RegexProvider.IsMatch(input, pattern));
        }
Ejemplo n.º 3
0
        public static bool IsNumber(string number)
        {
            if (IsNullOrEmpty(number))
            {
                return(false);
            }
            number = number.Trim();
            string pattern = "^[-]?[0-9]*[.]?[0-9]*$";

            return(RegexProvider.IsMatch(number, pattern));
        }
Ejemplo n.º 4
0
        public static bool IsPhone(string phone)
        {
            if (IsNullOrEmpty(phone))
            {
                return(false);
            }
            phone = phone.Trim();
            string pattern = @"^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$";

            return(RegexProvider.IsMatch(phone, pattern));
        }
Ejemplo n.º 5
0
        public static bool IsIdCard(string idCard)
        {
            if (IsNullOrEmpty(idCard))
            {
                return(true);
            }
            idCard = idCard.Trim();
            StringBuilder builder = new StringBuilder();

            builder.Append("^(11|12|13|14|15|21|22|23|31|32|33|34|35|36|37|41|42|43|44|45|46|");
            builder.Append("50|51|52|53|54|61|62|63|64|65|71|81|82|91)");
            builder.Append(@"(\d{13}|\d{15}[\dx])$");
            return(RegexProvider.IsMatch(idCard, builder.ToString()));
        }