Example #1
0
 public void SendKeysToOnlyNumbers(string value)
 {
     try
     {
         OnlyNumbers.SendKeys(value);
     }catch (NoSuchElementException e)
     {
         Console.WriteLine(e.Message);
     }
 }
Example #2
0
        public bool IsValidPhone(string phone)
        {
            if (String.IsNullOrWhiteSpace(phone))
            {
                return(false);
            }

            string numericPhone = OnlyNumbers.FetchOnlyNumbers(phone);

            return(IsValidLength(numericPhone) && IsValidCode(numericPhone) && IsValidNumberStart(numericPhone));
        }
Example #3
0
        public bool IsValidCep(string cep)
        {
            if (String.IsNullOrWhiteSpace(cep))
            {
                return(false);
            }

            string numericCep = OnlyNumbers.FetchOnlyNumbers(cep);

            return(IsValidLength(numericCep));
        }
Example #4
0
        public string Format(string cnpj)
        {
            if (string.IsNullOrWhiteSpace(cnpj))
            {
                return(string.Empty);
            }

            string numericCNPJ = OnlyNumbers.FetchOnlyNumbers(cnpj);

            return(Convert.ToUInt64(numericCNPJ.Substring(0, Math.Min(Constants.CNPJ_LENGHT, numericCNPJ.Length))).ToString(Constants.CNPJ_FORMAT_PATTERN));
        }
Example #5
0
        public bool IsValidCpf(string cpf)
        {
            if (String.IsNullOrWhiteSpace(cpf))
            {
                return(false);
            }

            string numericCpf = OnlyNumbers.FetchOnlyNumbers(cpf);

            return(IsValidLength(numericCpf) && !BelongsToBlacklist(numericCpf) && IsValidChecksum(numericCpf));
        }
Example #6
0
        public string Format(string cpf)
        {
            if (string.IsNullOrWhiteSpace(cpf))
            {
                return(string.Empty);
            }

            string numericCPF = OnlyNumbers.FetchOnlyNumbers(cpf);

            return(Convert.ToUInt64(numericCPF.Substring(0, Math.Min(Constants.CPF_LENGTH, numericCPF.Length))).ToString(Constants.CPF_FORMAT_PATTERN));
        }
Example #7
0
        public bool IsValidBoleto(string digitableLine)
        {
            if (string.IsNullOrWhiteSpace(digitableLine))
            {
                return(false);
            }

            digitableLine = OnlyNumbers.FetchOnlyNumbers(digitableLine);

            return(IsValidLength(digitableLine) &&
                   validateDigitableLinePartials(digitableLine) &&
                   Mod11(ParseDigitableLine(digitableLine).Remove(4, 1)).ToString().Equals(Convert.ToString(ParseDigitableLine(digitableLine)[4])));
        }
Example #8
0
        public static string Formatar(string cep)
        {
            var unformattedCEP = new OnlyNumbers(cep).ToString();

            if (unformattedCEP.Length != 8)
            {
                return(cep);
            }

            string pattern = @"{0:00\.000\-000}";

            return(String.Format(pattern, Convert.ToUInt64(unformattedCEP)));
        }
Example #9
0
        public void ReturnFalseGivenValueOf1()
        {
            var result = OnlyNumbers.FetchOnlyNumbers("032.721.340-00");

            Assert.Equal("03272134000", result);
        }
Example #10
0
        public void TestShouldReturnNumbers()
        {
            OnlyNumbers only = new OnlyNumbers("1$2@3aA-4%5!6/7?8#9*0 ");

            Assert.AreEqual("1234567890", only.ToString());
        }
Example #11
0
        public void TestShouldReturnEmpty()
        {
            OnlyNumbers only = new OnlyNumbers("");

            Assert.AreEqual("", only.ToString());
        }