Exemple #1
0
        public bool IsValidCep(string cep)
        {
            if (String.IsNullOrWhiteSpace(cep))
            {
                return(false);
            }

            string numericCep = OnlyNumbers.FetchOnlyNumbers(cep);

            return(IsValidLength(numericCep));
        }
Exemple #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));
        }
Exemple #3
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));
        }
Exemple #4
0
        public bool IsValidCpf(string cpf)
        {
            if (String.IsNullOrWhiteSpace(cpf))
            {
                return(false);
            }

            string numericCpf = OnlyNumbers.FetchOnlyNumbers(cpf);

            return(IsValidLength(numericCpf) && !BelongsToBlacklist(numericCpf) && IsValidChecksum(numericCpf));
        }
Exemple #5
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));
        }
Exemple #6
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])));
        }
Exemple #7
0
        public void ReturnFalseGivenValueOf1()
        {
            var result = OnlyNumbers.FetchOnlyNumbers("032.721.340-00");

            Assert.Equal("03272134000", result);
        }