internal CreatePayeeModelValidator(
            Email email,
            string payee,
            IGetPayeeByName getPayeeByName)
        {
            this.RuleFor(model => model.Name)
            .NotEmpty()
            .WithMessage("Payee name is required.")
            .MustAsync(async(name, _) => await getPayeeByName.GetResult(NewGetByIdParam(email, payee)) || payee.Equals(name))
            .WithMessage("Path payee must be equal to body payee.");

            this.RuleFor(model => model.Location)
            .SetValidator(new LocationModelValidator());
        }
        internal CreateConfigurationModelValidator(
            Email email,
            IGetCategoryByName getCategoryByName,
            IGetCurrencyByCode getCurrencyByCode,
            IGetPayeeByName getPayeeByName,
            IGetPaymentMethodByName getPaymentMethodByName)
        {
            this.RuleFor(model => model.Type)
            .NotEmpty()
            .WithMessage("Type is required.");

            this.RuleFor(model => model.PaymentMethod)
            .NotEmpty()
            .WithMessage("Payment method is required.")
            .MustAsync(async(method, _) => await getPaymentMethodByName.GetResult(NewGetByIdParam(email, method)))
            .WithMessage("Payment method not found.");

            this.RuleFor(model => model.Currency)
            .NotNull()
            .WithMessage("Currency is required.")
            .SetValidator(new CurrencyModelValidator(email, getCurrencyByCode));

            this.RuleFor(model => model.Payee)
            .NotEmpty()
            .WithMessage("Payee is required.")
            .MustAsync(async(payee, _) => await getPayeeByName.GetResult(NewGetByIdParam(email, payee.Name)))
            .WithMessage("Payee not found.");

            this.RuleFor(model => model.Category)
            .NotEmpty()
            .WithMessage("Category is required.")
            .MustAsync(async(category, _) => await getCategoryByName.GetResult(NewGetByIdParam(email, category.Name)))
            .WithMessage("Category not found.");

            this.RuleFor(model => model.Tags)
            .NotNull()
            .NotEmpty()
            .WithMessage("Must be at least one tag for configuration.");
        }
        internal CreateTransactionModelValidator(
            Email email,
            string?id,
            IGetCategoryByName getCategoryByName,
            IGetCurrencyByCode getCurrencyByCode,
            IGetPayeeByName getPayeeByName,
            IGetPaymentMethodByName getPaymentMethodByName,
            IGetTransactions getTransactions)
        {
            this.RuleFor(model => model)
            .MustAsync(async(transaction, _) =>
            {
                if (transaction?.Payment?.Cost == null)
                {
                    return(true);
                }

                var entities = await getTransactions.GetResult(NewGetByAllParam(
                                                                   email,
                                                                   NewFilterBuilder()
                                                                   .Where("year".Equal(transaction.Payment.Date.Year)
                                                                          .And("month".Equal(transaction.Payment.Date.Month))
                                                                          .And("day".Equal(transaction.Payment.Date.Day))
                                                                          .And("value".Equal(transaction.Payment.Cost.Value.ToString(GetCultureInfo("en-US"))))
                                                                          .And("category".Equal(transaction.Category))
                                                                          .And("currency".Equal(transaction.Payment.Cost.Currency.Code))
                                                                          .And("payee".Equal(transaction.Payee.Name))
                                                                          .And("paymentMethod".Equal(transaction.Payment.Method)))
                                                                   .Build()));

                return(entities
                       .Fold(true)(page => page.Data.All(@try => @try
                                                         .Fold(true)(item => id != default && item.Id.Equals(new Guid(id))))));
            })
            .WithMessage("Transaction already exists.");

            this.RuleFor(model => model.Type)
            .NotEmpty()
            .WithMessage("Type is required.");

            this.RuleFor(model => model.Payment)
            .NotNull()
            .WithMessage("Payment is required.")
            .SetValidator(new PaymentModelValidator(email, getCurrencyByCode, getPaymentMethodByName));

            this.RuleFor(model => model.Installment)
            .SetValidator(new CreateInstallmentModelValidator());

            this.RuleFor(model => model.Payee)
            .NotEmpty()
            .WithMessage("Payee is required.")
            .MustAsync(async(payee, _) => await getPayeeByName.GetResult(NewGetByIdParam(email, payee.Name)))
            .WithMessage("Payee not found.");

            this.RuleFor(model => model.Category)
            .NotEmpty()
            .WithMessage("Category is required.")
            .MustAsync(async(category, _) => await getCategoryByName.GetResult(NewGetByIdParam(email, category.Name)))
            .WithMessage("Category not found.");

            this.RuleFor(model => model.Tags)
            .NotNull()
            .NotEmpty()
            .WithMessage("Must be at least one tag for transaction.");
        }