Files
FrontOffice.BFF/src/FrontOffice.BFF.Application/UserWalletCQ/Queries/GetAllUserWalletChangeLog/GetAllUserWalletChangeLogQueryValidator.cs
masoodafar-web bcf2bc2a52 update
2025-12-02 03:32:50 +03:30

16 lines
784 B
C#

namespace FrontOffice.BFF.Application.UserWalletCQ.Queries.GetAllUserWalletChangeLog;
public class GetAllUserWalletChangeLogQueryValidator : AbstractValidator<GetAllUserWalletChangeLogQuery>
{
public GetAllUserWalletChangeLogQueryValidator()
{
RuleFor(x => x.ReferenceId).GreaterThan(0).When(x => x.ReferenceId.HasValue);
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllUserWalletChangeLogQuery>.CreateWithOptions((GetAllUserWalletChangeLogQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}