using FluentValidation; using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; namespace CMSMicroservice.Protobuf.Validator.UserWalletChangeLog; public class CreateNewUserWalletChangeLogRequestValidator : AbstractValidator { public CreateNewUserWalletChangeLogRequestValidator() { RuleFor(model => model.WalletId) .NotNull(); RuleFor(model => model.CurrentBalance) .NotNull(); RuleFor(model => model.ChangeValue) .NotNull(); RuleFor(model => model.CurrentNetworkBalance) .NotNull(); RuleFor(model => model.ChangeNerworkValue) .NotNull(); RuleFor(model => model.IsIncrease) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserWalletChangeLogRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); }; }