private string ValidateCNPJ(string CNPJ) { var helper = new CNPJHelper(); if (string.IsNullOrEmpty(CNPJ) || !helper.IsCNPJ(CNPJ)) { throw new CustomExceptions("CNPJ incorreto"); } return(helper.Clean(CNPJ)); }
private async Task Validate(string CNPJ, CNPJHelper helper) { if (!helper.IsCNPJ(CNPJ)) { throw new CustomExceptions("CNPJ incorreto"); } else if (!await _companyRepository.AnyAsync(x => x.CNPJ.Equals(helper.Clean(CNPJ)))) { throw new CustomExceptions("CNPJ não encontrado na base de dados"); } }