35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
namespace CMSMicroservice.Application.CommissionCQ.Queries.GetCommissionPayoutHistory;
|
|
|
|
public class GetCommissionPayoutHistoryQueryValidator : AbstractValidator<GetCommissionPayoutHistoryQuery>
|
|
{
|
|
public GetCommissionPayoutHistoryQueryValidator()
|
|
{
|
|
RuleFor(x => x.PayoutId)
|
|
.GreaterThan(0)
|
|
.WithMessage("شناسه پرداخت معتبر نیست")
|
|
.When(x => x.PayoutId.HasValue);
|
|
|
|
RuleFor(x => x.UserId)
|
|
.GreaterThan(0)
|
|
.WithMessage("شناسه کاربر معتبر نیست")
|
|
.When(x => x.UserId.HasValue);
|
|
RuleFor(x => x.WeekDefinitionId)
|
|
.NotNull()
|
|
.GreaterThan(0)
|
|
.WithMessage("شماره هفته نمیتواند خالی باشد");
|
|
}
|
|
|
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
|
{
|
|
var result = await ValidateAsync(
|
|
ValidationContext<GetCommissionPayoutHistoryQuery>.CreateWithOptions(
|
|
(GetCommissionPayoutHistoryQuery)model,
|
|
x => x.IncludeProperties(propertyName)));
|
|
|
|
if (result.IsValid)
|
|
return Array.Empty<string>();
|
|
|
|
return result.Errors.Select(e => e.ErrorMessage);
|
|
};
|
|
}
|