public void SendKeysToOnlyNumbers(string value) { try { OnlyNumbers.SendKeys(value); }catch (NoSuchElementException e) { Console.WriteLine(e.Message); } }
public bool IsValidPhone(string phone) { if (String.IsNullOrWhiteSpace(phone)) { return(false); } string numericPhone = OnlyNumbers.FetchOnlyNumbers(phone); return(IsValidLength(numericPhone) && IsValidCode(numericPhone) && IsValidNumberStart(numericPhone)); }
public bool IsValidCep(string cep) { if (String.IsNullOrWhiteSpace(cep)) { return(false); } string numericCep = OnlyNumbers.FetchOnlyNumbers(cep); return(IsValidLength(numericCep)); }
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)); }
public bool IsValidCpf(string cpf) { if (String.IsNullOrWhiteSpace(cpf)) { return(false); } string numericCpf = OnlyNumbers.FetchOnlyNumbers(cpf); return(IsValidLength(numericCpf) && !BelongsToBlacklist(numericCpf) && IsValidChecksum(numericCpf)); }
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)); }
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]))); }
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))); }
public void ReturnFalseGivenValueOf1() { var result = OnlyNumbers.FetchOnlyNumbers("032.721.340-00"); Assert.Equal("03272134000", result); }
public void TestShouldReturnNumbers() { OnlyNumbers only = new OnlyNumbers("1$2@3aA-4%5!6/7?8#9*0 "); Assert.AreEqual("1234567890", only.ToString()); }
public void TestShouldReturnEmpty() { OnlyNumbers only = new OnlyNumbers(""); Assert.AreEqual("", only.ToString()); }