diff --git a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs index 45049818c..6d731620c 100644 --- a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs +++ b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs @@ -76,14 +76,14 @@ namespace NzbDrone.Api.ClientSchema if (propertyInfo.PropertyType == typeof(int)) { - var value = Convert.ToInt32(field.Value); - propertyInfo.SetValue(target, value, null); + var value = field.Value.ToString().ParseInt32(); + propertyInfo.SetValue(target, value ?? 0, null); } else if (propertyInfo.PropertyType == typeof(long)) { - var value = Convert.ToInt64(field.Value); - propertyInfo.SetValue(target, value, null); + var value = field.Value.ToString().ParseInt64(); + propertyInfo.SetValue(target, value ?? 0, null); } else if (propertyInfo.PropertyType == typeof(int?)) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs index a7175dff6..679f422b4 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge public DelugeSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.MovieCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -"); } diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenSettings.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenSettings.cs index 5291c9515..f66dbb365 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken public HadoukenSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.Username).NotEmpty() .WithMessage("Username must not be empty."); diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexSettings.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexSettings.cs index 749ef9d04..211ba229d 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex public NzbVortexSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.ApiKey).NotEmpty() .WithMessage("API Key is required"); diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs index aff3f27ff..8b7a0c31d 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget public NzbgetSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.Username).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Password)); RuleFor(c => c.Password).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Username)); diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs index c02619f2f..b5127293d 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent public QBittorrentSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).InclusiveBetween(0, 65535); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); } } diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs index 0c1dc8221..00a8ef6b8 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd public SabnzbdSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.ApiKey).NotEmpty() .WithMessage("API Key is required when username/password are not configured") diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs index 9d0a860ec..aeb8887c4 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission public TransmissionSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.UrlBase).ValidUrlBase(); diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs index 4965c9a78..b978ec721 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs @@ -10,10 +10,10 @@ namespace NzbDrone.Core.Download.Clients.RTorrent public RTorrentSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).InclusiveBetween(0, 65535); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.MovieCategory).NotEmpty() .WithMessage("A category is recommended") - .AsWarning(); + .AsWarning(); } } diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs index 394fc53b4..8bf4c4ccb 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent public UTorrentSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).InclusiveBetween(0, 65535); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.TvCategory).NotEmpty(); } } diff --git a/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs b/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs index a8c1a9851..2af0ed9b8 100644 --- a/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs +++ b/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Email public EmailSettingsValidator() { RuleFor(c => c.Server).NotEmpty(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); RuleFor(c => c.From).NotEmpty(); RuleFor(c => c.To).NotEmpty(); } diff --git a/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs b/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs index 3c484dec7..55682003d 100644 --- a/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs +++ b/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Growl public GrowlSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); } } diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs b/src/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs index 34e9e4b75..d10993d79 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Plex public PlexClientSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); } } diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs index e792392ab..9a5d0587c 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Plex public PlexServerSettingsValidator() { RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).GreaterThan(0); + RuleFor(c => c.Port).InclusiveBetween(1, 65535); } }