IW4M-Admin/SharedLibraryCore/Configuration/Validation/ServerConfigurationValidator.cs

32 lines
915 B
C#
Raw Normal View History

using FluentValidation;
namespace SharedLibraryCore.Configuration.Validation
{
/// <summary>
2022-01-26 11:32:16 -05:00
/// Validation class for server configuration
/// </summary>
public class ServerConfigurationValidator : AbstractValidator<ServerConfiguration>
{
public ServerConfigurationValidator()
{
RuleFor(_server => _server.Port)
.InclusiveBetween(1, ushort.MaxValue);
RuleFor(_server => _server.Password)
.NotEmpty();
RuleForEach(_server => _server.Rules)
.NotEmpty();
RuleForEach(_server => _server.AutoMessages)
.NotEmpty();
RuleFor(_server => _server.ReservedSlotNumber)
.InclusiveBetween(0, 32);
RuleFor(_server => _server.CustomHostname)
.MinimumLength(3)
.MaximumLength(128);
}
}
2022-01-26 11:32:16 -05:00
}