Example #1
0
 void HandleTextChanged(object sender, TextChangedEventArgs e)
 {
     if (e.OldTextValue == null)
     {
         IsValid = null;
     }
     else
     {
         IsValid = (ValidationsUtil.IsCNPJValid(e.NewTextValue));
         ((Entry)sender).TextColor = IsValid.Value ? Color.Default : Color.Red;
     }
 }
Example #2
0
        public bool IsViewModelValid()
        {
            if (UsuarioModel.TipoApp != TipoAppModel.CLIENTE && UsuarioModel.TipoApp != TipoAppModel.FORNECEDOR)
            {
                throw new InvalidViewModelException("O tipo de aplicativo deve ser cliente ou fornecedor");
            }

            if (string.IsNullOrEmpty(UsuarioModel.PessoaJuridicaModel.CNPJ) ||
                string.IsNullOrWhiteSpace(UsuarioModel.PessoaJuridicaModel.CNPJ))
            {
                throw new InvalidViewModelException("CNPJ é obrigatório");
            }

            if (ValidationsUtil.IsCNPJValid(UsuarioModel.PessoaJuridicaModel.CNPJ) == false)
            {
                throw new InvalidViewModelException("CNPJ não está em um formato correto");
            }

            if (string.IsNullOrEmpty(UsuarioModel.PessoaJuridicaModel.RazaoSocial) ||
                string.IsNullOrWhiteSpace(UsuarioModel.PessoaJuridicaModel.RazaoSocial))
            {
                throw new InvalidViewModelException("Nome fantasia é obrigatório");
            }

            if (string.IsNullOrEmpty(UsuarioModel.Email) || string.IsNullOrWhiteSpace(UsuarioModel.Email))
            {
                throw new InvalidViewModelException("Email é obrigatório");
            }

            if (ValidationsUtil.IsEmailValid(UsuarioModel.Email) == false)
            {
                throw new InvalidViewModelException("Email não está em um formato correto");
            }

            if (string.IsNullOrEmpty(UsuarioModel.Senha) || string.IsNullOrWhiteSpace(UsuarioModel.Senha))
            {
                throw new InvalidViewModelException("Senha é obrigatória");
            }

            if (UsuarioModel.Senha.Equals(ConfirmacaoSenha) == false)
            {
                throw new InvalidViewModelException("Senha e confirmação de senha devem ser iguais");
            }

            return(true);
        }