Files
CMS/src/CMSMicroservice.Application/UserWalletCQ/Commands/UpdateUserWallet/UpdateUserWalletCommandValidator.cs
2025-11-12 02:24:02 +03:30

21 lines
841 B
C#

namespace CMSMicroservice.Application.UserWalletCQ.Commands.UpdateUserWallet;
public class UpdateUserWalletCommandValidator : AbstractValidator<UpdateUserWalletCommand>
{
public UpdateUserWalletCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
RuleFor(model => model.UserId)
.NotNull();
RuleFor(model => model.Balance)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdateUserWalletCommand>.CreateWithOptions((UpdateUserWalletCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}