예제 #1
0
        public async Task Adicionar(Cliente cliente)
        {
            if (!cliente.EhValido())
            {
                Notificar(cliente.ValidationResult);
                return;
            }

            if (!CPFValidation.Validar(cliente.CPF))
            {
                Notificar("Cliente com CPF inválido");
                return;
            }

            if (_clienteRepository.Buscar(c => c.CPF == cliente.CPF).Any())
            {
                Notificar("Já existe um cliente com este CPF informado.");
                return;
            }


            await _clienteRepository.Adicionar(cliente);

            await _UoW.Commit();
        }
예제 #2
0
 public void Valido()
 {
     if (!(CPFValidation.Validar(CPF)))
     {
         throw new Exception("CPF Invalido");
     }
 }
        public PacienteValidation()
        {
            RuleFor(p => p.Cpf)
            .NotNull()
            .NotEmpty()
            .WithMessage("Cpf é obrigatório");

            RuleFor(p => CPFValidation.Validar(p.Cpf))
            .Equal(true)
            .WithMessage("Informe um cpf válido");

            RuleFor(p => p.Nome)
            .NotNull()
            .NotEmpty()
            .WithMessage("Nome é obrigatório")
            .Length(1, 35)
            .WithMessage("Nome deve ter até 35 caracteres");

            RuleFor(p => p.Sexo)
            .NotNull()
            .NotEmpty()
            .Length(1, 10)
            .WithMessage("Sexo é obrigatório");

            RuleFor(p => p.Cor)
            .NotNull()
            .NotEmpty()
            .Length(1, 10)
            .WithMessage("Cor é obrigatório");

            RuleFor(p => p.Nascimento)
            .NotNull()
            .WithMessage("Data de nascimento é obrigatória");
        }
예제 #4
0
        public Document(string number)
        {
            Number = number;

            AddNotifications(new ValidationContract()
                             .Requires()
                             .IsTrue(CPFValidation.Validate(Number), "Document", "Cpf invalido")
                             );
        }
        public void Validate()
        {
            if (CanValidate())
            {
                var test = CPFValidation.Test(property.Value);

                SetStatus(test, ERROR_CODE.INVALID);
            }
        }
예제 #6
0
        public bool IsSatisfiedBy(Cliente cliente)
        {
            //CPF vazio
            if (string.IsNullOrEmpty(cliente.Cpf))
            {
                return(true);
            }

            return(CPFValidation.Validar(cliente.Cpf));
        }
예제 #7
0
        private void ValidateCPF(bool unique = false)
        {
            var cpfValidation = new CPFValidation(_repository);

            RuleFor(c => c.cpf)
            .NotEmpty().WithMessage("'CPF' não pode ser vazio.")
            .Must(CPFValidation.IsCpf).WithMessage("CPF inválido.");

            if (unique)
            {
                RuleFor(c => c.password).Must(cpfValidation.IsUnique).WithMessage("O CPF já esta em uso.");
            }
        }
예제 #8
0
        public SupplierValidation()
        {
            RuleFor(s => s.Name)
            .NotEmpty().WithMessage("The field  {PropertyName} is required.")
            .Length(2, 100)
            .WithMessage("The field {PropertyName} needs to have between {MinLength} and {MaxLength} characters.");

            When(s => s.SupplierType == SupplierType.Person, () =>
            {
                RuleFor(s => s.DocumentNumber.Length).Equal(CPFValidation.CPFLenght)
                .WithMessage("This documento needs to have {ComparisonValue} characters e has {PropertyValue}.");
                RuleFor(s => CPFValidation.Validate(s.DocumentNumber)).Equal(true)
                .WithMessage("This document number is not valid.");
            });

            When(s => s.SupplierType == SupplierType.LegalPerson, () =>
            {
                RuleFor(s => s.DocumentNumber.Length).Equal(CNPJValidation.CNPJLength)
                .WithMessage("O campo Documento precisa ter {ComparisonValue} caracteres e foi fornecido {PropertyValue}.");
                RuleFor(s => CNPJValidation.Validate(s.DocumentNumber)).Equal(true)
                .WithMessage("This document number is not valid.");
            });
        }
 public bool IsSatisfiedBy(Cliente cliente)
 {
     return(CPFValidation.Validar(cliente.CPF));
 }
 public bool IsSatisfiedBy(Student student)
 {
     return(CPFValidation.Validar(student.CPF));
 }
예제 #11
0
 public override bool IsValid()
 {
     ValidationResult = new CPFValidation().Validate(this);
     return(ValidationResult.IsValid);
 }
 public bool IsSatisfiedBy(Membro membro)
 {
     return(CPFValidation.Validar(membro.CPF));
 }
 public bool IsSatisfiedBy(Aluno aluno)
 {
     return(CPFValidation.Validar(aluno.CPF));
 }
예제 #14
0
 public bool EhValido()
 {
     return(CPFValidation.Validar(Numero));
 }
예제 #15
0
 public bool IsSatisfiedBy(string cpf)
 {
     return(CPFValidation.Validar(cpf));
 }