1using FluentValidation;
2using NzbDrone.Common.Extensions;
3using NzbDrone.Core.Annotations;
4using NzbDrone.Core.ThingiProvider;
5using NzbDrone.Core.Validation;
6
7namespace NzbDrone.Core.Download.Clients.UTorrent
8{
9 public class UTorrentSettingsValidator : AbstractValidator<UTorrentSettings>
10 {
11 public UTorrentSettingsValidator()
12 {
13 RuleFor(c => c.Host).ValidHost();
14 RuleFor(c => c.Port).InclusiveBetween(1, 65535);
15 RuleFor(c => c.UrlBase).ValidUrlBase().When(c => c.UrlBase.IsNotNullOrWhiteSpace());
16 RuleFor(c => c.MovieCategory).NotEmpty();
17 }
18 }
19
20 public class UTorrentSettings : IProviderConfig
21 {
22 private static readonly UTorrentSettingsValidator Validator = new UTorrentSettingsValidator();
23
24 public UTorrentSettings()
25 {
26 Host = "localhost";
27 Port = 8080;
28 MovieCategory = "radarr";
…lines 29–61 unchanged (33 lines)
62 public int OlderMoviePriority { get; set; }
63
64 [FieldDefinition(10, Label = "DownloadClientSettingsInitialState", Type = FieldType.Select, SelectOptions = typeof(UTorrentState), HelpText = "DownloadClientSettingsInitialStateHelpText")]
65 [FieldToken(TokenField.HelpText, "DownloadClientSettingsInitialState", "clientName", "uTorrent")]
66 public int IntialState { get; set; }
67
68 public NzbDroneValidationResult Validate()
69 {
70 return new NzbDroneValidationResult(Validator.Validate(this));
71 }
72 }
73}
74