-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRabbitMqTransportConfigValidator.cs
More file actions
32 lines (27 loc) · 1019 Bytes
/
RabbitMqTransportConfigValidator.cs
File metadata and controls
32 lines (27 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using BuslyCLI.Config.Transports;
using FluentValidation;
namespace BuslyCLI.Config.Validators;
public class RabbitMqTransportConfigValidator : AbstractValidator<RabbitmqTransportConfig>
{
public RabbitMqTransportConfigValidator()
{
RuleFor(x => x.AmqpConnectionString)
.NotEmpty();
RuleFor(x => x.RoutingTopology)
.IsInEnum();
RuleFor(x => x.ManagementApi)
.SetValidator(new ManagementApiConfigValidator());
}
}
public class ManagementApiConfigValidator : AbstractValidator<ManagementApi>
{
public ManagementApiConfigValidator()
{
RuleFor(x => x)
.Must(x =>
(string.IsNullOrEmpty(x.UserName) && string.IsNullOrEmpty(x.Password)) // both empty
|| (!string.IsNullOrEmpty(x.UserName) && !string.IsNullOrEmpty(x.Password)) // both set
)
.WithMessage("Username and Password are mutually dependent: if one is set, the other must also be set.");
}
}