public VehicleValidator(IVehicleRepository vehicleRepository, IUserRepository userRepository) { _vehicleRepository = vehicleRepository; RuleFor(c => c.Description).NotEmpty().WithMessage(ValidatorMessages.FieldIsRequired("Descrição")); RuleFor(c => c.Description).MaximumLength(200).WithMessage(ValidatorMessages.FieldMaxLength("Descrição", 200)); RuleFor(c => c).Must(VehicleExists).When(c => c.Id > 0).WithMessage(ValidatorMessages.NotFound("Veículo")); }
public UserValidator(IUserRepository userRepository) { _userRepository = userRepository; RuleFor(u => u.NickName).MinimumLength(4).WithMessage(ValidatorMessages.FieldMinLength("Nick Name", 4)); RuleFor(u => u.Password).MinimumLength(8).WithMessage(ValidatorMessages.FieldMinLength("Senha", 8)); RuleFor(u => u).Must(ValidNickNameInUse).WithMessage(ValidatorMessages.User.NickNameAlreadyInUse); RuleFor(u => u).Must(ValidNickNamePattern).WithMessage(ValidatorMessages.User.NickNamePattern); }
public RecurringExpenseValidator(IRecurringExpenseRepository recurringExpenseRepository, ICreditCardRepository creditCardRepository) { _recurringExpenseRepository = recurringExpenseRepository; _creditCardRepository = creditCardRepository; RuleFor(p => p.Description).NotEmpty().WithMessage(ValidatorMessages.FieldIsRequired("Descrição")); RuleFor(s => s.Value).GreaterThan(0).WithMessage(ValidatorMessages.GreaterThan("Valor", 0)); RuleFor(p => p).Must(ValidCreditCard).WithMessage(ValidatorMessages.NotFound("Cartão de Crédito")); RuleFor(p => p).Must(ValidRecurringExpense).When(p => p.Id > 0).WithMessage(ValidatorMessages.NotFound("Despesa Recorrente")); }
public HouseholdExpenseValidator(IHouseholdExpenseRepository repository, IVehicleRepository vehicleRepository) { _vehicleRepository = vehicleRepository; RuleFor(s => s.Date).NotEqual(default(System.DateTime)).WithMessage(ValidatorMessages.FieldIsRequired("Data")); RuleFor(s => s.Description).NotEmpty().WithMessage(ValidatorMessages.FieldIsRequired("Descrição")); RuleFor(s => s.Value).GreaterThan(0).WithMessage(ValidatorMessages.GreaterThan("Valor", 0)); RuleFor(s => s.Type).IsInEnum().WithMessage("Tipo inválido"); RuleFor(c => c).Must(VehicleExists).WithMessage(ValidatorMessages.NotFound("Veículo")); }
public EarningValidator(IEarningRepository repository) { _repository = repository; RuleFor(s => s.Description).NotEmpty().WithMessage(ValidatorMessages.FieldIsRequired("Descrição")); RuleFor(s => s.Date).NotEqual(default(System.DateTime)).WithMessage(ValidatorMessages.FieldIsRequired("Data")); RuleFor(s => s.Value).GreaterThan(0).WithMessage(ValidatorMessages.GreaterThan("Valor", 0)); RuleFor(s => s.Type).IsInEnum().WithMessage("Tipo inválido."); RuleFor(s => s).Must(EarningExists).When(p => p.Id > 0).WithMessage(ValidatorMessages.NotFound("Benefício/Salário")); }
public CreditCardValidator(ICreditCardRepository creditCardRepository, IUserRepository userRepository) { _creditCardRepository = creditCardRepository; _userRepository = userRepository; RuleFor(c => c.Name).NotEmpty().WithMessage(ValidatorMessages.FieldIsRequired("Nome")); RuleFor(c => c.InvoiceClosingDay).InclusiveBetween(1, 30).WithMessage(ValidatorMessages.BetweenValue("Dia de fechamento da fatura", 1, 30)); RuleFor(c => c.InvoiceDueDay).InclusiveBetween(1, 30).WithMessage(ValidatorMessages.BetweenValue("Dia de vencimento da fatura", 1, 30)); RuleFor(c => c).Must(CreditCardExists).When(c => c.Id > 0).WithMessage(ValidatorMessages.NotFound("Cartão de Crédito")); RuleFor(c => c).Must(UserExists).WithMessage(ValidatorMessages.NotFound("Usuário")); }
public RecurringExpenseHistoryValidator(IRecurringExpenseRepository recurringExpenseRepository, int userId) { _recurringExpenseRepository = recurringExpenseRepository; _userId = userId; RuleFor(p => p.Date).NotEqual(default(System.DateTime)).WithMessage(ValidatorMessages.FieldIsRequired("Data")); RuleFor(s => s.PaidValue).GreaterThan(0).WithMessage(ValidatorMessages.FieldIsRequired("Valor Pago")); RuleFor(p => p).Must(ValidMonthYear).WithMessage("Já existe um histórico para este mês ano."); RuleFor(p => p).Must(ValidRecurringExpense).WithMessage(ValidatorMessages.NotFound("Despesa Recorrente")); RuleFor(p => p).Must(ValidRecurringExpense).When(p => p.Id > 0).WithMessage(ValidatorMessages.NotFound("Despesa Recorrente")); }
public PaymentValidator(IPaymentRepository paymentRepository, ICreditCardRepository creditCardRepository) { _paymentRepository = paymentRepository; _creditCardRepository = creditCardRepository; RuleFor(p => p.Description).NotEmpty().WithMessage(ValidatorMessages.FieldIsRequired("Descrição")); RuleFor(p => p.Installments).NotEmpty().WithMessage(ValidatorMessages.Payment.InstallmentsRequired); RuleFor(p => p.TypeId).IsInEnum().WithMessage(ValidatorMessages.Payment.PaymentTypeInvalid); RuleFor(p => p).Must(ValidCreditCard).WithMessage(ValidatorMessages.NotFound("Cartão de Crédito")); RuleFor(p => p).Must(ValidPayment).When(p => p.Id > 0).WithMessage(ValidatorMessages.NotFound("Pagamento")); RuleFor(p => p.Installments).Custom(ValidateInstallments); }
public FuelExpensesValidator(IVehicleRepository vehicleRepository, IFuelExpensesRepository fuelExpensesRepository, int userId) { _userId = userId; _vehicleRepository = vehicleRepository; _fuelExpensesRepository = fuelExpensesRepository; RuleFor(c => c.Miliage).GreaterThan(0).WithMessage(ValidatorMessages.MinValue("Quilometragem", 0)); RuleFor(c => c.Miliage).LessThan(1000000000).WithMessage(ValidatorMessages.MaxValue("Quilometragem", 999999999)); RuleFor(c => c.PricePerLiter).GreaterThan(0).WithMessage(ValidatorMessages.MinValue("Preço por Litro", 0)); RuleFor(c => c.PricePerLiter).LessThan(1000000000).WithMessage(ValidatorMessages.MaxValue("Preço por Litro", 999999999)); RuleFor(c => c.ValueSupplied).GreaterThan(0).WithMessage(ValidatorMessages.MinValue("Valor Abastecido", 0)); RuleFor(c => c.ValueSupplied).LessThan(1000000000).WithMessage(ValidatorMessages.MaxValue("Valor Abastecido", 999999999)); RuleFor(c => c.Date).NotEqual(default(DateTime)).WithMessage(ValidatorMessages.FieldIsRequired("Data")); RuleFor(c => c).Must(VehicleExists).WithMessage(ValidatorMessages.NotFound("Veículo")); RuleFor(c => c).Must(FuelExpensesExists).When(c => c.Id > 0).WithMessage(ValidatorMessages.NotFound("Despesa de combustível")); RuleFor(c => c).Must(DataMiliageIsMatch).WithMessage("Data e Quilometragem não batem devido à outro abastecimento"); }