using FluentValidation; namespace PnvPanel.Application.Admin.Users; public sealed class AdminSetUserPlanCommandValidator : AbstractValidator { public AdminSetUserPlanCommandValidator() { RuleFor(x => x) .Must(x => x.PlanId.HasValue ^ x.CustomConfigCount.HasValue) .WithMessage("Укажите либо PlanId, либо CustomConfigCount — ровно одно из двух."); When( x => x.CustomConfigCount.HasValue, () => RuleFor(x => x.CustomConfigCount!.Value).GreaterThanOrEqualTo(-1) ); } }