Radarr/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs

64 lines
1.8 KiB
C#
Raw Normal View History

2013-05-19 23:17:32 +00:00
using System;
using FluentValidation;
using FluentValidation.Results;
2013-05-19 23:17:32 +00:00
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
2013-05-19 23:17:32 +00:00
2013-05-27 05:44:54 +00:00
namespace NzbDrone.Core.Notifications.Email
2013-05-19 23:17:32 +00:00
{
public class EmailSettingsValidator : AbstractValidator<EmailSettings>
{
public EmailSettingsValidator()
{
RuleFor(c => c.Server).NotEmpty();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.From).NotEmpty();
RuleFor(c => c.To).NotEmpty();
}
}
public class EmailSettings : IProviderConfig
2013-05-19 23:17:32 +00:00
{
private static readonly EmailSettingsValidator Validator = new EmailSettingsValidator();
2013-08-09 06:22:26 +00:00
public EmailSettings()
{
Port = 25;
}
2013-05-27 05:44:54 +00:00
[FieldDefinition(0, Label = "Server", HelpText = "Hostname or IP of Email server")]
2013-05-19 23:17:32 +00:00
public String Server { get; set; }
2013-05-27 05:44:54 +00:00
[FieldDefinition(1, Label = "Port")]
2013-05-19 23:17:32 +00:00
public Int32 Port { get; set; }
[FieldDefinition(2, Label = "SSL", Type = FieldType.Checkbox)]
public Boolean Ssl { get; set; }
2013-05-19 23:17:32 +00:00
2013-05-27 05:44:54 +00:00
[FieldDefinition(3, Label = "Username")]
2013-05-19 23:17:32 +00:00
public String Username { get; set; }
[FieldDefinition(4, Label = "Password", Type = FieldType.Password)]
2013-05-19 23:17:32 +00:00
public String Password { get; set; }
[FieldDefinition(5, Label = "From Address")]
2013-05-19 23:17:32 +00:00
public String From { get; set; }
2013-05-27 05:44:54 +00:00
[FieldDefinition(6, Label = "Recipient Address")]
2013-05-19 23:17:32 +00:00
public String To { get; set; }
public bool IsValid
{
get
{
return !string.IsNullOrWhiteSpace(Server) && Port > 0 && !string.IsNullOrWhiteSpace(From) && !string.IsNullOrWhiteSpace(To);
}
}
public ValidationResult Validate()
{
return Validator.Validate(this);
}
2013-05-19 23:17:32 +00:00
}
}