diff --git a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs index 0687a1413..0a7acb9e1 100644 --- a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs +++ b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs @@ -73,14 +73,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 b5fd1153e..7d9375570 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.TvCategory).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 411624c9d..e35f48f01 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 cbd104964..59acfde42 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 fa6908f2c..9bb87ce63 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 22a3389bf..a4f21b70a 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 633ee7a57..d551c05d3 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 81715246c..dba98c99a 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs @@ -10,7 +10,7 @@ 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.TvCategory).NotEmpty() .WithMessage("A category is recommended") .AsWarning(); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs index a5e5b006f..52185b134 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); } }