Exemple #1
0
        public virtual void Validar()
        {
            if (string.IsNullOrEmpty(NomeFantasia))
            {
                throw new ExcecaoEmitenteSemNome();
            }

            if (NomeFantasia.Length < 5)
            {
                throw new ExcecaoNomeEmitentePequeno();
            }

            if (string.IsNullOrEmpty(RazaoSocial))
            {
                throw new ExcecaoEmitenteSemRazaoSocial();
            }

            if (RazaoSocial.Length < 5)
            {
                throw new ExcecaoRazaoSocialEmitentePequeno();
            }

            if (CNPJ == null)
            {
                throw new ExcecaoEmitenteSemCNPJ();
            }

            if (string.IsNullOrEmpty(InscricaoEstadual))
            {
                throw new ExcecaoEmitenteSemInscricaoEstadual();
            }

            if (!InscricaoEstadual.All(char.IsDigit) && !InscricaoEstadual.Contains("."))
            {
                throw new ExcecaoInscricacaoEstadualEmitenteComLetras();
            }

            if (InscricaoEstadual.Length > 15)
            {
                throw new ExcecaoEmitenteComInscricaoEstadualAcimaDoLimite();
            }

            if (string.IsNullOrEmpty(InscricaoMunicipal))
            {
                throw new ExcecaoEmitenteSemInscricaoMunicipal();
            }

            if (!InscricaoMunicipal.All(char.IsDigit))
            {
                throw new ExcecaoInscricacaoMunicipalEmitenteComLetras();
            }

            if (Endereco == null)
            {
                throw new ExcecaoEmitenteSemEndereco();
            }

            CNPJ.Validar();

            Endereco.Validar();
        }